mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-09-11 07:55:34 +03:00
* fix: check temp path permission on mac os * chore: format code
This commit is contained in:
parent
78fc841370
commit
8ee8f09390
5
.changes/check-permission-on-macos.md
Normal file
5
.changes/check-permission-on-macos.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"tauri": "patch:bug"
|
||||
---
|
||||
|
||||
Fix check temporary path permission on macos.
|
@ -293,7 +293,7 @@ pub fn resolve_path<P: AsRef<Path>>(
|
||||
BaseDirectory::App => app_config_dir(config),
|
||||
#[allow(deprecated)]
|
||||
BaseDirectory::Log => app_log_dir(config),
|
||||
BaseDirectory::Temp => Some(temp_dir()),
|
||||
BaseDirectory::Temp => temp_dir().canonicalize().ok(),
|
||||
BaseDirectory::AppConfig => app_config_dir(config),
|
||||
BaseDirectory::AppData => app_data_dir(config),
|
||||
BaseDirectory::AppLocalData => app_local_data_dir(config),
|
||||
|
@ -42,7 +42,7 @@ impl Cmd {
|
||||
}
|
||||
|
||||
fn tempdir<R: Runtime>(_context: InvokeContext<R>) -> super::Result<PathBuf> {
|
||||
Ok(std::env::temp_dir())
|
||||
Ok(std::env::temp_dir().canonicalize()?)
|
||||
}
|
||||
|
||||
fn locale<R: Runtime>(_context: InvokeContext<R>) -> super::Result<Option<String>> {
|
||||
|
@ -391,4 +391,29 @@ mod tests {
|
||||
assert!(scope.is_allowed("C:\\home\\tauri\\anyfile"));
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn check_temp_dir() {
|
||||
use std::{
|
||||
env::temp_dir,
|
||||
fs::{remove_file, write},
|
||||
};
|
||||
|
||||
let scope = new_scope();
|
||||
scope
|
||||
.allow_directory(temp_dir().canonicalize().unwrap(), true)
|
||||
.unwrap();
|
||||
|
||||
let test_temp_file = temp_dir().canonicalize().unwrap().join("tauri_test_file");
|
||||
if test_temp_file.exists() {
|
||||
remove_file(test_temp_file.clone()).unwrap();
|
||||
}
|
||||
|
||||
assert!(scope.is_allowed(test_temp_file.clone()));
|
||||
|
||||
write(test_temp_file.clone(), ".").unwrap();
|
||||
|
||||
assert!(scope.is_allowed(test_temp_file.clone()));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user