summaryrefslogtreecommitdiff
path: root/cli/proc_state.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/proc_state.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/proc_state.rs')
-rw-r--r--cli/proc_state.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/cli/proc_state.rs b/cli/proc_state.rs
index eb672d8d0..0dd97b5e3 100644
--- a/cli/proc_state.rs
+++ b/cli/proc_state.rs
@@ -59,7 +59,7 @@ use deno_runtime::deno_node::NodeResolutionMode;
use deno_runtime::deno_tls::rustls::RootCertStore;
use deno_runtime::deno_web::BlobStore;
use deno_runtime::inspector_server::InspectorServer;
-use deno_runtime::permissions::Permissions;
+use deno_runtime::permissions::PermissionsContainer;
use import_map::ImportMap;
use log::warn;
use std::collections::HashSet;
@@ -181,7 +181,7 @@ impl ProcState {
let maybe_import_map =
if let Some(import_map_specifier) = maybe_import_map_specifier {
let file = file_fetcher
- .fetch(&import_map_specifier, &mut Permissions::allow_all())
+ .fetch(&import_map_specifier, PermissionsContainer::allow_all())
.await
.context(format!(
"Unable to load '{}' import map",
@@ -289,8 +289,8 @@ impl ProcState {
roots: Vec<ModuleSpecifier>,
is_dynamic: bool,
lib: TsTypeLib,
- root_permissions: Permissions,
- dynamic_permissions: Permissions,
+ root_permissions: PermissionsContainer,
+ dynamic_permissions: PermissionsContainer,
reload_on_watch: bool,
) -> Result<(), AnyError> {
log::debug!("Preparing module load.");
@@ -490,8 +490,8 @@ impl ProcState {
specifiers,
false,
lib,
- Permissions::allow_all(),
- Permissions::allow_all(),
+ PermissionsContainer::allow_all(),
+ PermissionsContainer::allow_all(),
false,
)
.await
@@ -668,8 +668,8 @@ impl ProcState {
cache::FetchCacher::new(
self.emit_cache.clone(),
self.file_fetcher.clone(),
- Permissions::allow_all(),
- Permissions::allow_all(),
+ PermissionsContainer::allow_all(),
+ PermissionsContainer::allow_all(),
)
}