diff options
Diffstat (limited to 'ext/fs')
-rw-r--r-- | ext/fs/lib.rs | 14 | ||||
-rw-r--r-- | ext/fs/ops.rs | 13 |
2 files changed, 22 insertions, 5 deletions
diff --git a/ext/fs/lib.rs b/ext/fs/lib.rs index d27712927..b028b12c1 100644 --- a/ext/fs/lib.rs +++ b/ext/fs/lib.rs @@ -23,7 +23,8 @@ use std::path::Path; use std::rc::Rc; pub trait FsPermissions { - fn check_read(&mut self, p: &Path, api_name: &str) -> Result<(), AnyError>; + fn check_read(&mut self, path: &Path, api_name: &str) + -> Result<(), AnyError>; fn check_read_all(&mut self, api_name: &str) -> Result<(), AnyError>; fn check_read_blind( &mut self, @@ -31,7 +32,16 @@ pub trait FsPermissions { display: &str, api_name: &str, ) -> Result<(), AnyError>; - fn check_write(&mut self, p: &Path, api_name: &str) -> Result<(), AnyError>; + fn check_write( + &mut self, + path: &Path, + api_name: &str, + ) -> Result<(), AnyError>; + fn check_write_partial( + &mut self, + path: &Path, + api_name: &str, + ) -> Result<(), AnyError>; fn check_write_all(&mut self, api_name: &str) -> Result<(), AnyError>; fn check_write_blind( &mut self, diff --git a/ext/fs/ops.rs b/ext/fs/ops.rs index 083d1b15f..da52318a4 100644 --- a/ext/fs/ops.rs +++ b/ext/fs/ops.rs @@ -294,9 +294,16 @@ where let fs = { let mut state = state.borrow_mut(); - state - .borrow_mut::<P>() - .check_write(&path, "Deno.remove()")?; + if recursive { + state + .borrow_mut::<P>() + .check_write(&path, "Deno.remove()")?; + } else { + state + .borrow_mut::<P>() + .check_write_partial(&path, "Deno.remove()")?; + } + state.borrow::<FileSystemRc>().clone() }; |