Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions crates/base/src/deno_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -653,8 +653,10 @@ where
let build_file_system_fn =
|base_fs: Arc<dyn deno_fs::FileSystem>| -> Result<Arc<dyn deno_fs::FileSystem>, AnyError> {
let tmp_fs = TmpFs::try_from(maybe_tmp_fs_config.unwrap_or_default())?;
let fs = PrefixFs::new("/tmp", tmp_fs, Some(base_fs))
.tmp_dir("/tmp");
let tmp_fs_actual_path = tmp_fs.actual_path().to_path_buf();
let fs = PrefixFs::new("/tmp", tmp_fs.clone(), Some(base_fs))
.tmp_dir("/tmp")
.add_fs(tmp_fs_actual_path, tmp_fs);

Ok(if let Some(s3_fs) = maybe_s3_fs_config.map(S3Fs::new).transpose()? {
maybe_s3_fs = Some(s3_fs.clone());
Expand Down
15 changes: 15 additions & 0 deletions crates/base/test_cases/use-tmp-fs-3/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const meowFile = await Deno.create('/tmp/meow');
const meow = new TextEncoder().encode('meowmeow');
await meowFile.write(meow);

const meowRealPath = Deno.realPathSync('/tmp/meow');
const meowFileContent = await Deno.readTextFile(meowRealPath);
const isValid = meowFileContent == 'meowmeow';

export default {
fetch() {
return new Response(null, {
status: isValid ? 200 : 500,
});
},
};
1 change: 0 additions & 1 deletion crates/base/test_cases/user-worker-san-check/.blocklisted
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ openSync
readDirSync
readLink
readLinkSync
realPathSync
removeSync
rename
renameSync
Expand Down
17 changes: 17 additions & 0 deletions crates/base/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2826,6 +2826,23 @@ async fn test_tmp_fs_usage() {
TerminationToken::new()
);
}

{
integration_test!(
"./test_cases/main",
NON_SECURE_PORT,
"use-tmp-fs-3",
None,
None,
None,
None,
(|resp| async {
let resp = resp.unwrap();
assert_eq!(resp.status().as_u16(), 200);
}),
TerminationToken::new()
);
}
}

#[tokio::test]
Expand Down
6 changes: 6 additions & 0 deletions crates/fs/impl/tmp_fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,12 @@ pub struct TmpFs {
quota: Arc<Quota>,
}

impl TmpFs {
pub fn actual_path(&self) -> &Path {
self.root.path()
}
}

#[async_trait::async_trait(?Send)]
impl deno_fs::FileSystem for TmpFs {
fn cwd(&self) -> FsResult<PathBuf> {
Expand Down
1 change: 1 addition & 0 deletions ext/core/js/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,7 @@ globalThis.bootstrapSBEdge = (opts, ctx) => {
'open': true,
'stat': true,
'realPath': true,
'realPathSync': true,
'create': true,
'remove': true,
'writeFile': true,
Expand Down