mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-01-11 20:00:29 +01:00
Bail out if sync directory is deleted
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user