diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-01-07 17:25:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-07 17:25:34 +0100 |
commit | fac64478157ee563b185edb5734688e4523df3a1 (patch) | |
tree | 888d562982e1fc37dfb9a4459928bcec84d55dfc /runtime/ops/fs_events.rs | |
parent | 82e930726ee5dbac8e6eae0962c07c72daf9843c (diff) |
refactor(permissions): add PermissionsContainer struct for internal mutability (#17134)
Turns out we were cloning permissions which after prompting were discarded,
so the state of permissions was never preserved. To handle that we need to store
all permissions behind "Arc<Mutex<>>" (because there are situations where we
need to send them to other thread).
Testing and benching code still uses "Permissions" in most places - it's undesirable
to share the same permission set between various test/bench files - otherwise
granting or revoking permissions in one file would influence behavior of other test
files.
Diffstat (limited to 'runtime/ops/fs_events.rs')
-rw-r--r-- | runtime/ops/fs_events.rs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/runtime/ops/fs_events.rs b/runtime/ops/fs_events.rs index d7c4b4670..6cda48ef3 100644 --- a/runtime/ops/fs_events.rs +++ b/runtime/ops/fs_events.rs @@ -1,6 +1,6 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -use crate::permissions::Permissions; +use crate::permissions::PermissionsContainer; use deno_core::error::AnyError; use deno_core::parking_lot::Mutex; use deno_core::AsyncRefCell; @@ -119,9 +119,8 @@ fn op_fs_events_open( for path in &args.paths { let path = PathBuf::from(path); state - .borrow_mut::<Permissions>() - .read - .check(&path, Some("Deno.watchFs()"))?; + .borrow_mut::<PermissionsContainer>() + .check_read(&path, "Deno.watchFs()")?; watcher.watch(&path, recursive_mode)?; } let resource = FsEventsResource { |