summaryrefslogtreecommitdiff
path: root/cli/cache/mod.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-01-07 17:25:34 +0100
committerGitHub <noreply@github.com>2023-01-07 17:25:34 +0100
commitfac64478157ee563b185edb5734688e4523df3a1 (patch)
tree888d562982e1fc37dfb9a4459928bcec84d55dfc /cli/cache/mod.rs
parent82e930726ee5dbac8e6eae0962c07c72daf9843c (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 'cli/cache/mod.rs')
-rw-r--r--cli/cache/mod.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/cli/cache/mod.rs b/cli/cache/mod.rs
index 68bf1e4c6..d2ad1b20a 100644
--- a/cli/cache/mod.rs
+++ b/cli/cache/mod.rs
@@ -11,7 +11,7 @@ use deno_graph::source::CacheInfo;
use deno_graph::source::LoadFuture;
use deno_graph::source::LoadResponse;
use deno_graph::source::Loader;
-use deno_runtime::permissions::Permissions;
+use deno_runtime::permissions::PermissionsContainer;
use std::sync::Arc;
mod check;
@@ -42,17 +42,17 @@ pub const CACHE_PERM: u32 = 0o644;
/// a concise interface to the DENO_DIR when building module graphs.
pub struct FetchCacher {
emit_cache: EmitCache,
- dynamic_permissions: Permissions,
+ dynamic_permissions: PermissionsContainer,
file_fetcher: Arc<FileFetcher>,
- root_permissions: Permissions,
+ root_permissions: PermissionsContainer,
}
impl FetchCacher {
pub fn new(
emit_cache: EmitCache,
file_fetcher: FileFetcher,
- root_permissions: Permissions,
- dynamic_permissions: Permissions,
+ root_permissions: PermissionsContainer,
+ dynamic_permissions: PermissionsContainer,
) -> Self {
let file_fetcher = Arc::new(file_fetcher);
@@ -104,7 +104,7 @@ impl Loader for FetchCacher {
}
let specifier = specifier.clone();
- let mut permissions = if is_dynamic {
+ let permissions = if is_dynamic {
self.dynamic_permissions.clone()
} else {
self.root_permissions.clone()
@@ -113,7 +113,7 @@ impl Loader for FetchCacher {
async move {
file_fetcher
- .fetch(&specifier, &mut permissions)
+ .fetch(&specifier, permissions)
.await
.map_or_else(
|err| {