mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 17:34:47 -05:00
feat: hash file names in gen cache (#6911)
This commit is contained in:
parent
d54d4d21bd
commit
9d50c5c1a6
8 changed files with 30 additions and 9 deletions
|
@ -1,4 +1,5 @@
|
||||||
use crate::fs as deno_fs;
|
use crate::fs as deno_fs;
|
||||||
|
use crate::http_cache::url_to_filename;
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
@ -50,7 +51,7 @@ impl DiskCache {
|
||||||
out.push(scheme);
|
out.push(scheme);
|
||||||
|
|
||||||
match scheme {
|
match scheme {
|
||||||
"http" | "https" | "wasm" => {
|
"wasm" => {
|
||||||
let host = url.host_str().unwrap();
|
let host = url.host_str().unwrap();
|
||||||
let host_port = match url.port() {
|
let host_port = match url.port() {
|
||||||
// Windows doesn't support ":" in filenames, so we represent port using a
|
// Windows doesn't support ":" in filenames, so we represent port using a
|
||||||
|
@ -64,6 +65,7 @@ impl DiskCache {
|
||||||
out.push(path_seg);
|
out.push(path_seg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
"http" | "https" => out = url_to_filename(url),
|
||||||
"file" => {
|
"file" => {
|
||||||
let path = url.to_file_path().unwrap();
|
let path = url.to_file_path().unwrap();
|
||||||
let mut path_components = path.components();
|
let mut path_components = path.components();
|
||||||
|
@ -194,15 +196,15 @@ mod tests {
|
||||||
let mut test_cases = vec![
|
let mut test_cases = vec![
|
||||||
(
|
(
|
||||||
"http://deno.land/std/http/file_server.ts",
|
"http://deno.land/std/http/file_server.ts",
|
||||||
"http/deno.land/std/http/file_server.ts",
|
"http/deno.land/d8300752800fe3f0beda9505dc1c3b5388beb1ee45afd1f1e2c9fc0866df15cf",
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"http://localhost:8000/std/http/file_server.ts",
|
"http://localhost:8000/std/http/file_server.ts",
|
||||||
"http/localhost_PORT8000/std/http/file_server.ts",
|
"http/localhost_PORT8000/d8300752800fe3f0beda9505dc1c3b5388beb1ee45afd1f1e2c9fc0866df15cf",
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"https://deno.land/std/http/file_server.ts",
|
"https://deno.land/std/http/file_server.ts",
|
||||||
"https/deno.land/std/http/file_server.ts",
|
"https/deno.land/d8300752800fe3f0beda9505dc1c3b5388beb1ee45afd1f1e2c9fc0866df15cf",
|
||||||
),
|
),
|
||||||
("wasm://wasm/d1c677ea", "wasm/wasm/d1c677ea"),
|
("wasm://wasm/d1c677ea", "wasm/wasm/d1c677ea"),
|
||||||
];
|
];
|
||||||
|
@ -251,12 +253,12 @@ mod tests {
|
||||||
(
|
(
|
||||||
"http://deno.land/std/http/file_server.ts",
|
"http://deno.land/std/http/file_server.ts",
|
||||||
"js",
|
"js",
|
||||||
"http/deno.land/std/http/file_server.ts.js",
|
"http/deno.land/d8300752800fe3f0beda9505dc1c3b5388beb1ee45afd1f1e2c9fc0866df15cf.js",
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"http://deno.land/std/http/file_server.ts",
|
"http://deno.land/std/http/file_server.ts",
|
||||||
"js.map",
|
"js.map",
|
||||||
"http/deno.land/std/http/file_server.ts.js.map",
|
"http/deno.land/d8300752800fe3f0beda9505dc1c3b5388beb1ee45afd1f1e2c9fc0866df15cf.js.map",
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[WILDCARD]
|
[WILDCARD]
|
||||||
local: [WILDCARD]http[WILDCARD]127.0.0.1_PORT4545[WILDCARD]
|
local: [WILDCARD]http[WILDCARD]127.0.0.1_PORT4545[WILDCARD]
|
||||||
type: TypeScript
|
type: TypeScript
|
||||||
compiled: [WILDCARD]048_media_types_jsx.ts.js
|
compiled: [WILDCARD].js
|
||||||
deps:
|
deps:
|
||||||
http://127.0.0.1:4545/cli/tests/048_media_types_jsx.ts
|
http://127.0.0.1:4545/cli/tests/048_media_types_jsx.ts
|
||||||
├── http://localhost:4545/cli/tests/subdir/mt_text_typescript_tsx.t1.tsx
|
├── http://localhost:4545/cli/tests/subdir/mt_text_typescript_tsx.t1.tsx
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
local: [WILDCARD]005_more_imports.ts
|
local: [WILDCARD]005_more_imports.ts
|
||||||
type: TypeScript
|
type: TypeScript
|
||||||
compiled: [WILDCARD]005_more_imports.ts.js
|
compiled: [WILDCARD].js
|
||||||
deps:
|
deps:
|
||||||
file://[WILDCARD]/005_more_imports.ts
|
file://[WILDCARD]/005_more_imports.ts
|
||||||
└─┬ file://[WILDCARD]/subdir/mod1.ts
|
└─┬ file://[WILDCARD]/subdir/mod1.ts
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"local": "[WILDCARD]005_more_imports.ts",
|
"local": "[WILDCARD]005_more_imports.ts",
|
||||||
"fileType": "TypeScript",
|
"fileType": "TypeScript",
|
||||||
"compiled": "[WILDCARD]005_more_imports.ts.js",
|
"compiled": "[WILDCARD].js",
|
||||||
"map": null,
|
"map": null,
|
||||||
"deps": [
|
"deps": [
|
||||||
"file://[WILDCARD]/005_more_imports.ts",
|
"file://[WILDCARD]/005_more_imports.ts",
|
||||||
|
|
1
cli/tests/import_file_with_colon.ts
Normal file
1
cli/tests/import_file_with_colon.ts
Normal file
|
@ -0,0 +1 @@
|
||||||
|
import "http://localhost:4545/cli/tests/subdir/file_with_:_in_name.ts";
|
1
cli/tests/import_file_with_colon.ts.out
Normal file
1
cli/tests/import_file_with_colon.ts.out
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Hello from file_with_:_in_name.ts
|
|
@ -2220,6 +2220,12 @@ itest!(compiler_js_error {
|
||||||
exit_code: 1,
|
exit_code: 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
itest!(import_file_with_colon {
|
||||||
|
args: "run --quiet --reload import_file_with_colon.ts",
|
||||||
|
output: "import_file_with_colon.ts.out",
|
||||||
|
http_server: true,
|
||||||
|
});
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn cafile_env_fetch() {
|
fn cafile_env_fetch() {
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
|
@ -354,6 +354,17 @@ pub async fn run_all_servers() {
|
||||||
HeaderValue::from_static("application/javascript"),
|
HeaderValue::from_static("application/javascript"),
|
||||||
);
|
);
|
||||||
res
|
res
|
||||||
|
}))
|
||||||
|
.or(warp::path!("cli"/"tests"/"subdir"/"file_with_:_in_name.ts").map(|| {
|
||||||
|
let mut res = Response::new(Body::from(
|
||||||
|
"console.log('Hello from file_with_:_in_name.ts');",
|
||||||
|
));
|
||||||
|
let h = res.headers_mut();
|
||||||
|
h.insert(
|
||||||
|
"Content-type",
|
||||||
|
HeaderValue::from_static("application/typescript"),
|
||||||
|
);
|
||||||
|
res
|
||||||
}));
|
}));
|
||||||
|
|
||||||
let content_type_handler = warp::any()
|
let content_type_handler = warp::any()
|
||||||
|
|
Loading…
Add table
Reference in a new issue