diff --git a/Cargo.lock b/Cargo.lock index 7c541d7..7c1b18c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -458,7 +458,7 @@ checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" dependencies = [ "cfg-if", "libc", - "wasi", + "wasi 0.10.2+wasi-snapshot-preview1", ] [[package]] @@ -593,15 +593,6 @@ dependencies = [ "hashbrown", ] -[[package]] -name = "instant" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "716d3d89f35ac6a34fd0eed635395f4c3b76fa889338a4632e5231a8684216bd" -dependencies = [ - "cfg-if", -] - [[package]] name = "ipnet" version = "2.3.1" @@ -644,9 +635,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.103" +version = "0.2.119" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8f7255a17a627354f321ef0055d63b898c6fb27eff628af4d1b66b7331edf6" +checksum = "1bf2e165bb3457c8e098ea76f3e3bc9db55f87aa90d52d0e6be741470916aaa4" [[package]] name = "linked-hash-map" @@ -656,9 +647,9 @@ checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" [[package]] name = "lock_api" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109" +checksum = "88943dd7ef4a2e5a4bfa2753aaab3013e34ce2533d1996fb18ef591e315e2b3b" dependencies = [ "scopeguard", ] @@ -708,14 +699,15 @@ dependencies = [ [[package]] name = "mio" -version = "0.7.13" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c2bdb6314ec10835cd3293dd268473a835c02b7b352e788be788b3c6ca6bb16" +checksum = "7ba42135c6a5917b9db9cd7b293e5409e1c6b041e6f9825e92e55a894c63b6f8" dependencies = [ "libc", "log", "miow", "ntapi", + "wasi 0.11.0+wasi-snapshot-preview1", "winapi", ] @@ -875,27 +867,25 @@ dependencies = [ [[package]] name = "parking_lot" -version = "0.11.2" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +checksum = "87f5ec2493a61ac0506c0f4199f99070cbe83857b0337006a30f3e6719b8ef58" dependencies = [ - "instant", "lock_api", "parking_lot_core", ] [[package]] name = "parking_lot_core" -version = "0.8.5" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" +checksum = "28141e0cc4143da2443301914478dc976a61ffdb3f043058310c70df2fed8954" dependencies = [ "cfg-if", - "instant", "libc", "redox_syscall", "smallvec", - "winapi", + "windows-sys", ] [[package]] @@ -1221,9 +1211,9 @@ checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" [[package]] name = "socket2" -version = "0.4.2" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dc90fe6c7be1a323296982db1836d1ea9e47b6839496dde9a541bc496df3516" +checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0" dependencies = [ "libc", "winapi", @@ -1319,11 +1309,10 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.12.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2c2416fdedca8443ae44b4527de1ea633af61d8f7169ffa6e72c5b53d24efcc" +checksum = "2af73ac49756f3f7c01172e34a23e5d0216f6c32333757c2c61feb2bbff5a5ee" dependencies = [ - "autocfg", "bytes", "libc", "memchr", @@ -1333,15 +1322,16 @@ dependencies = [ "parking_lot", "pin-project-lite", "signal-hook-registry", + "socket2", "tokio-macros", "winapi", ] [[package]] name = "tokio-macros" -version = "1.4.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "154794c8f499c2619acd19e839294703e9e32e7630ef5f46ea80d4ef0fbee5eb" +checksum = "b557f72f448c511a979e2564e55d74e6c4432fc96ff4f6241bc6bded342643b7" dependencies = [ "proc-macro2", "quote", @@ -1486,6 +1476,12 @@ version = "0.10.2+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + [[package]] name = "wasm-bindgen" version = "0.2.78" @@ -1586,6 +1582,49 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-sys" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3df6e476185f92a12c072be4a189a0210dcdcf512a1891d6dff9edb874deadc6" +dependencies = [ + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_msvc" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8e92753b1c443191654ec532f14c199742964a061be25d77d7a96f09db20bf5" + +[[package]] +name = "windows_i686_gnu" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a711c68811799e017b6038e0922cb27a5e2f43a2ddb609fe0b6f3eeda9de615" + +[[package]] +name = "windows_i686_msvc" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "146c11bb1a02615db74680b32a68e2d61f553cc24c4eb5b4ca10311740e44172" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c912b12f7454c6620635bbff3450962753834be2a594819bd5e945af18ec64bc" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "504a2476202769977a040c6364301a3f65d0cc9e3fb08600b2bda150a0488316" + [[package]] name = "winreg" version = "0.7.0" diff --git a/Cargo.toml b/Cargo.toml index 105ddfb..d14042d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ steam_shortcuts_util = "^1.1.4" steamgriddb_api = "^0.2,0" serde = { version = "^1.0.130", features = ["derive"] } serde_json = "^1.0.68" -tokio = { version = "^1.11.0", features = ["full"] } +tokio = { version = "^1.17.0", features = ["full"] } reqwest = { version = "^0.11.4", default_features = false } config = "^0.11.0" failure = "^0.1.8" diff --git a/src/settings.rs b/src/settings.rs index 6c61ad9..8875fe3 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -8,7 +8,7 @@ use config::{Config, ConfigError, Environment, File}; use serde::{Deserialize, Serialize}; use std::env; -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Clone)] pub struct Settings { pub debug: bool, pub epic_games: EpicGamesLauncherSettings, @@ -50,8 +50,6 @@ impl Settings { sanitize_auth_key(&mut result); - - result } diff --git a/src/steamgriddb/settings.rs b/src/steamgriddb/settings.rs index ebc47df..fb94d4f 100644 --- a/src/steamgriddb/settings.rs +++ b/src/steamgriddb/settings.rs @@ -1,6 +1,6 @@ use serde::{Deserialize, Serialize}; -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, Serialize, Deserialize,Clone)] pub struct SteamGridDbSettings { pub enabled: bool, pub auth_key: Option, diff --git a/src/ui/ui.rs b/src/ui/ui.rs index 79f98ee..45be4a8 100644 --- a/src/ui/ui.rs +++ b/src/ui/ui.rs @@ -30,10 +30,20 @@ pub async fn run_ui() -> Result<(), Box> { let synch_ui = ui.clone(); let sync_settings = settings.clone(); synch_bytton.set_callback(move |cb| { - update_settings_with_ui_values(&mut sync_settings.borrow_mut(), &synch_ui); - match block_on(run_sync(&sync_settings.borrow())) { + let mut settings_clone = sync_settings.borrow().clone(); + update_settings_with_ui_values(&mut settings_clone, &synch_ui); + use tokio::task; + let task = task::spawn_blocking(move || { + let setting_ref = settings_clone.clone(); + let synchro_task = run_sync(&setting_ref); + match block_on(synchro_task) { + Ok(_) => println!("Finished sync"), + Err(e) => println!("{}", e), + } + }); + match block_on(task){ Ok(_) => cb.set_label("Synched"), - Err(e) => println!("{}", e), + Err(_) => cb.set_label("Error Synching"), } }); } @@ -78,7 +88,6 @@ fn update_settings_with_ui_values(settings: &mut Settings, ui: &UserInterface) { settings.gog.location = empty_or_whitespace(ui.gog_folder_input.value()); settings.gog.wine_c_drive = empty_or_whitespace(ui.gog_winedrive_input.value()); - // Uplay settings.uplay.enabled = ui.enable_uplay_checkbox.value(); } @@ -184,6 +193,6 @@ fn update_ui_with_settings(ui: &mut UserInterface, settings: &Settings) { { ui.gog_winedrive_input.hide(); } - + ui.enable_uplay_checkbox.set_value(settings.uplay.enabled); }