diff --git a/src-tauri/yaak-sync/src/commands.rs b/src-tauri/yaak-sync/src/commands.rs index a5710deb..5840b3a2 100644 --- a/src-tauri/yaak-sync/src/commands.rs +++ b/src-tauri/yaak-sync/src/commands.rs @@ -12,6 +12,7 @@ use tauri::ipc::Channel; use tauri::{command, AppHandle, Listener, Runtime}; use tokio::sync::watch; use ts_rs::TS; +use crate::error::Error::InvalidSyncDirectory; #[command] pub async fn calculate( @@ -19,6 +20,10 @@ pub async fn calculate( workspace_id: &str, sync_dir: &Path, ) -> Result> { + if !sync_dir.exists() { + return Err(InvalidSyncDirectory(sync_dir.to_string_lossy().to_string())) + } + let db_candidates = get_db_candidates(&app_handle, workspace_id, sync_dir)?; let fs_candidates = get_fs_candidates(sync_dir)? .into_iter() diff --git a/src-tauri/yaak-sync/src/error.rs b/src-tauri/yaak-sync/src/error.rs index 978a08da..868e29c4 100644 --- a/src-tauri/yaak-sync/src/error.rs +++ b/src-tauri/yaak-sync/src/error.rs @@ -6,7 +6,7 @@ use thiserror::Error; pub enum Error { #[error("Yaml error: {0}")] YamlParseError(#[from] serde_yaml::Error), - + #[error("Sync parse error: {0}")] ParseError(String), @@ -25,6 +25,9 @@ pub enum Error { #[error("Invalid sync file: {0}")] InvalidSyncFile(String), + #[error("Invalid sync directory: {0}")] + InvalidSyncDirectory(String), + #[error("Watch error: {0}")] NotifyError(#[from] notify::Error), }