summaryrefslogtreecommitdiff
path: root/cli/global_state.rs
diff options
context:
space:
mode:
authorNayeem Rahman <muhammed.9939@gmail.com>2020-01-20 14:45:44 +0000
committerRy Dahl <ry@tinyclouds.org>2020-01-20 09:45:44 -0500
commit7f80f9db3f4c3b064b230adfec7ff958fc195da6 (patch)
treebda74057420a1b51ce293918b6e67123715ee945 /cli/global_state.rs
parent60b53fd6b6dc2af83a64c332b9f3a1926f43d631 (diff)
refactor: Improve path handling in permission checks (#3714)
Diffstat (limited to 'cli/global_state.rs')
-rw-r--r--cli/global_state.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/cli/global_state.rs b/cli/global_state.rs
index d42a50a76..1709a3429 100644
--- a/cli/global_state.rs
+++ b/cli/global_state.rs
@@ -19,6 +19,7 @@ use std;
use std::env;
use std::future::Future;
use std::ops::Deref;
+use std::path::Path;
use std::str;
use std::sync::Arc;
use std::sync::Mutex;
@@ -175,12 +176,12 @@ impl ThreadSafeGlobalState {
}
#[inline]
- pub fn check_read(&self, filename: &str) -> Result<(), ErrBox> {
+ pub fn check_read(&self, filename: &Path) -> Result<(), ErrBox> {
self.permissions.check_read(filename)
}
#[inline]
- pub fn check_write(&self, filename: &str) -> Result<(), ErrBox> {
+ pub fn check_write(&self, filename: &Path) -> Result<(), ErrBox> {
self.permissions.check_write(filename)
}
@@ -221,7 +222,7 @@ impl ThreadSafeGlobalState {
.into_os_string()
.into_string()
.unwrap();
- self.check_read(&filename)?;
+ self.check_read(Path::new(&filename))?;
Ok(())
}
_ => Err(permission_denied()),