From 63d2785b2f6fe65a66a5685f7c9e7f68020949cd Mon Sep 17 00:00:00 2001 From: Wyatt Verchere Date: Mon, 17 Apr 2023 16:07:09 -0700 Subject: [PATCH] Deadlock fixes (#85) * fixed deadlock * added missing files to commit * clippy & dist --- .cargo/config.toml | 2 +- theseus/src/api/profile.rs | 28 ++++++++++++++++------------ theseus/src/state/dirs.rs | 1 + theseus_gui/.gitignore | 2 -- theseus_gui/dist/.gitignore | 3 +++ theseus_gui/src-tauri/Cargo.toml | 2 +- 6 files changed, 22 insertions(+), 16 deletions(-) create mode 100644 theseus_gui/dist/.gitignore diff --git a/.cargo/config.toml b/.cargo/config.toml index ca80597fc..37c78c26b 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,3 +1,3 @@ # Windows has stack overflows when calling from Tauri, so we increase compiler size [target.'cfg(windows)'] -rustflags = ["-C", "link-args=/STACK:4194304"] \ No newline at end of file +rustflags = ["-C", "link-args=/STACK:8388608"] \ No newline at end of file diff --git a/theseus/src/api/profile.rs b/theseus/src/api/profile.rs index 2a62cac62..a1092245d 100644 --- a/theseus/src/api/profile.rs +++ b/theseus/src/api/profile.rs @@ -89,19 +89,23 @@ pub async fn list() -> crate::Result #[tracing::instrument] pub async fn sync(path: &Path) -> crate::Result<()> { let state = State::get().await?; - let mut profiles = state.profiles.write().await; + let result = { + let mut profiles: tokio::sync::RwLockWriteGuard< + crate::state::Profiles, + > = state.profiles.write().await; - if let Some(profile) = profiles.0.get_mut(path) { - profile.sync().await?; - State::sync().await?; - - Ok(()) - } else { - Err( - crate::ErrorKind::UnmanagedProfileError(path.display().to_string()) - .as_error(), - ) - } + if let Some(profile) = profiles.0.get_mut(path) { + profile.sync().await?; + Ok(()) + } else { + Err(crate::ErrorKind::UnmanagedProfileError( + path.display().to_string(), + ) + .as_error()) + } + }; + State::sync().await?; + result } /// Add a project from a version diff --git a/theseus/src/state/dirs.rs b/theseus/src/state/dirs.rs index 4e5c0769e..6d1ec237b 100644 --- a/theseus/src/state/dirs.rs +++ b/theseus/src/state/dirs.rs @@ -26,6 +26,7 @@ impl DirectoryInfo { "Could not find valid config dir".to_string(), ))?; + dbg!(&config_dir); fs::create_dir_all(&config_dir).await.map_err(|err| { crate::ErrorKind::FSError(format!( "Error creating Theseus config directory: {err}" diff --git a/theseus_gui/.gitignore b/theseus_gui/.gitignore index 5bc838d0d..8a0449091 100644 --- a/theseus_gui/.gitignore +++ b/theseus_gui/.gitignore @@ -10,8 +10,6 @@ pnpm-debug.log* lerna-debug.log* node_modules -dist -dist-ssr *.local # Editor directories and files diff --git a/theseus_gui/dist/.gitignore b/theseus_gui/dist/.gitignore new file mode 100644 index 000000000..59c3b7198 --- /dev/null +++ b/theseus_gui/dist/.gitignore @@ -0,0 +1,3 @@ +# exclude everything except this file +* +!.gitignore diff --git a/theseus_gui/src-tauri/Cargo.toml b/theseus_gui/src-tauri/Cargo.toml index 895beef00..dd2701619 100644 --- a/theseus_gui/src-tauri/Cargo.toml +++ b/theseus_gui/src-tauri/Cargo.toml @@ -19,7 +19,7 @@ theseus = { path = "../../theseus", features = ["tauri"] } serde_json = "1.0" serde = { version = "1.0", features = ["derive"] } -tauri = { version = "1.2", features = ["protocol-asset", "window-close", "window-create", "dialog"] } +tauri = { version = "1.2", features = ["dialog", "protocol-asset", "window-close", "window-create"] } tokio = { version = "1", features = ["full"] } thiserror = "1.0" tokio-stream = { version = "0.1", features = ["fs"] }