summaryrefslogtreecommitdiff
path: root/cli/tools/repl/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/tools/repl/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/tools/repl/mod.rs')
-rw-r--r--cli/tools/repl/mod.rs7
1 files changed, 5 insertions, 2 deletions
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<i32, AnyError> {
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?;