Skip to content

Commit

Permalink
fix: app no longer takes ages to load from p-scope
Browse files Browse the repository at this point in the history
  • Loading branch information
Tormak9970 committed Apr 21, 2023
1 parent 595b442 commit 8002a01
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 65 deletions.
23 changes: 0 additions & 23 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ tauri-build = { version = "1.1", features = [] }
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.1", features = ["dialog-all", "fs-all", "http-request", "os-all", "path-all", "process-exit", "protocol-all", "shell-open", "updater", "window-all"] }
tauri-plugin-persisted-scope = "0.1.0"
chrono = "0.4.23"
home = "0.5.4"
vdf-serde = "0.3.0"
Expand Down
55 changes: 14 additions & 41 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,53 +290,26 @@ fn add_steam_to_scope(app_handle: &AppHandle) {
let fs_scope = app_handle.fs_scope();
let asset_scope = app_handle.asset_protocol_scope();

if !FsScope::is_allowed(&fs_scope, steam_parent_dir) {
let fs_res = FsScope::allow_directory(&fs_scope, steam_parent_dir, true);

if fs_res.is_err() {
let err = fs_res.err().unwrap();
logger::log_to_file(app_handle.to_owned(), format!("Error adding Steam directory to scope. FS Scope Error: {}", err.to_string()).as_str(), 0);
} else {
logger::log_to_file(app_handle.to_owned(), "Added Steam directory to FS scope.", 0);
}
} else {
logger::log_to_file(app_handle.to_owned(), "Steam directory already allowed in FS scope.", 0);
}

if !FsScope::is_allowed(&asset_scope, steam_parent_dir) {
let asset_res = FsScope::allow_directory(&asset_scope, steam_parent_dir, true);

if asset_res.is_err() {
let err = asset_res.err().unwrap();
logger::log_to_file(app_handle.to_owned(), format!("Error adding Steam directory to scope. Asset Scope Error: {}", err.to_string()).as_str(), 0);
} else {
logger::log_to_file(app_handle.to_owned(), "Added Steam directory to Asset scope.", 0);
}
let fs_res = FsScope::allow_directory(&fs_scope, steam_parent_dir, true);
let asset_res = FsScope::allow_directory(&asset_scope, steam_parent_dir, true);

if fs_res.is_ok() && asset_res.is_ok() {
logger::log_to_file(app_handle.to_owned(), "Added Steam directory to scope.", 0);
} else if fs_res.is_err() {
let err = fs_res.err().unwrap();
logger::log_to_file(app_handle.to_owned(), format!("Error adding Steam directory to scope. FS Scope Error: {}", err.to_string()).as_str(), 0);
} else if asset_res.is_err() {
let err = asset_res.err().unwrap();
logger::log_to_file(app_handle.to_owned(), format!("Error adding Steam directory to scope. Asset Scope Error: {}", err.to_string()).as_str(), 0);
} else {
logger::log_to_file(app_handle.to_owned(), "Steam directory already allowed in Asset scope.", 0);
let fs_err = fs_res.err().unwrap();
let asset_err = asset_res.err().unwrap();
logger::log_to_file(app_handle.to_owned(), format!("Error adding Steam directory to scope. FS Scope Error: {}. Asset Scope Error: {}", fs_err.to_string(), asset_err.to_string()).as_str(), 0);
}

// let fs_res = FsScope::allow_directory(&fs_scope, steam_parent_dir, true);
// let asset_res = FsScope::allow_directory(&asset_scope, steam_parent_dir, true);

// if fs_res.is_ok() && asset_res.is_ok() {
// logger::log_to_file(app_handle.to_owned(), "Added Steam directory to scope.", 0);
// } else if fs_res.is_err() {
// let err = fs_res.err().unwrap();
// logger::log_to_file(app_handle.to_owned(), format!("Error adding Steam directory to scope. FS Scope Error: {}", err.to_string()).as_str(), 0);
// } else if asset_res.is_err() {
// let err = asset_res.err().unwrap();
// logger::log_to_file(app_handle.to_owned(), format!("Error adding Steam directory to scope. Asset Scope Error: {}", err.to_string()).as_str(), 0);
// } else {
// let fs_err = fs_res.err().unwrap();
// let asset_err = asset_res.err().unwrap();
// logger::log_to_file(app_handle.to_owned(), format!("Error adding Steam directory to scope. FS Scope Error: {}. Asset Scope Error: {}", fs_err.to_string(), asset_err.to_string()).as_str(), 0);
// }
}

fn main() {
tauri::Builder::default()
.plugin(tauri_plugin_persisted_scope::init())
.invoke_handler(tauri::generate_handler![
logger::clean_out_log,
logger::log_to_file,
Expand Down

0 comments on commit 8002a01

Please sign in to comment.