Bail out if sync directory is deleted

This commit is contained in:
Gregory Schier
2025-11-19 13:42:48 -08:00
parent 0e98a3e498
commit bddc6e35a0
2 changed files with 9 additions and 1 deletions

View File

@@ -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<R: Runtime>(
@@ -19,6 +20,10 @@ pub async fn calculate<R: Runtime>(
workspace_id: &str,
sync_dir: &Path,
) -> Result<Vec<SyncOp>> {
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()

View File

@@ -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),
}