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 /cli/lsp/registries.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 'cli/lsp/registries.rs')
| -rw-r--r-- | cli/lsp/registries.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/cli/lsp/registries.rs b/cli/lsp/registries.rs index 81e2552c0..c8e5dad60 100644 --- a/cli/lsp/registries.rs +++ b/cli/lsp/registries.rs @@ -30,7 +30,7 @@ use deno_core::url::Url; use deno_core::ModuleSpecifier; use deno_graph::Dependency; use deno_runtime::deno_web::BlobStore; -use deno_runtime::permissions::Permissions; +use deno_runtime::permissions::PermissionsContainer; use log::error; use once_cell::sync::Lazy; use regex::Regex; @@ -519,7 +519,7 @@ impl ModuleRegistry { .file_fetcher .fetch_with_accept( specifier, - &mut Permissions::allow_all(), + PermissionsContainer::allow_all(), Some("application/vnd.deno.reg.v2+json, application/vnd.deno.reg.v1+json;q=0.9, application/json;q=0.8"), ) .await; @@ -617,7 +617,7 @@ impl ModuleRegistry { .ok()?; let file = self .file_fetcher - .fetch(&endpoint, &mut Permissions::allow_all()) + .fetch(&endpoint, PermissionsContainer::allow_all()) .await .ok()?; let documentation: lsp::Documentation = @@ -973,7 +973,7 @@ impl ModuleRegistry { let specifier = Url::parse(url).ok()?; let file = self .file_fetcher - .fetch(&specifier, &mut Permissions::allow_all()) + .fetch(&specifier, PermissionsContainer::allow_all()) .await .ok()?; serde_json::from_str(&file.source).ok() @@ -1030,7 +1030,7 @@ impl ModuleRegistry { let specifier = ModuleSpecifier::parse(url).ok()?; let file = self .file_fetcher - .fetch(&specifier, &mut Permissions::allow_all()) + .fetch(&specifier, PermissionsContainer::allow_all()) .await .map_err(|err| { error!( @@ -1066,7 +1066,7 @@ impl ModuleRegistry { .ok()?; let file = self .file_fetcher - .fetch(&specifier, &mut Permissions::allow_all()) + .fetch(&specifier, PermissionsContainer::allow_all()) .await .map_err(|err| { error!( |
