From b91a3ab4d29ceb4b45efd3c792c65f2b3712cfda Mon Sep 17 00:00:00 2001 From: trivernis Date: Wed, 3 Nov 2021 19:36:51 +0100 Subject: [PATCH] Add shutting down of daemons when the repository is changed Signed-off-by: trivernis --- mediarepo-api/src/tauri_plugin/commands/repo.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mediarepo-api/src/tauri_plugin/commands/repo.rs b/mediarepo-api/src/tauri_plugin/commands/repo.rs index 245aa2e..0471d10 100644 --- a/mediarepo-api/src/tauri_plugin/commands/repo.rs +++ b/mediarepo-api/src/tauri_plugin/commands/repo.rs @@ -104,6 +104,15 @@ pub async fn select_repository( .ok_or(PluginError::from( format!("Repository '{}' not found", name).as_str(), ))?; + if let Some(path) = app_state + .active_repo + .read() + .await + .clone() + .and_then(|r| r.path) + { + app_state.stop_running_daemon(&path).await?; + } let address = if let Some(address) = &repo.address { address.clone() } else {