From fac64478157ee563b185edb5734688e4523df3a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Sat, 7 Jan 2023 17:25:34 +0100 Subject: 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>" (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. --- cli/tools/repl/mod.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'cli/tools/repl') diff --git a/cli/tools/repl/mod.rs b/cli/tools/repl/mod.rs index fc03dee2f..00f10b7d6 100644 --- a/cli/tools/repl/mod.rs +++ b/cli/tools/repl/mod.rs @@ -8,6 +8,7 @@ use crate::worker::create_main_worker; use deno_core::error::AnyError; use deno_core::resolve_url_or_path; use deno_runtime::permissions::Permissions; +use deno_runtime::permissions::PermissionsContainer; use rustyline::error::ReadlineError; mod cdp; @@ -72,7 +73,7 @@ async fn read_eval_file( let file = ps .file_fetcher - .fetch(&specifier, &mut Permissions::allow_all()) + .fetch(&specifier, PermissionsContainer::allow_all()) .await?; Ok((*file.source).to_string()) @@ -84,7 +85,9 @@ pub async fn run(flags: Flags, repl_flags: ReplFlags) -> Result { let mut worker = create_main_worker( &ps, main_module.clone(), - Permissions::from_options(&ps.options.permissions_options())?, + PermissionsContainer::new(Permissions::from_options( + &ps.options.permissions_options(), + )?), ) .await?; worker.setup_repl().await?; -- cgit v1.2.3