mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-06-12 17:34:27 +02: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 tauri::{command, AppHandle, Listener, Runtime};
|
||||||
use tokio::sync::watch;
|
use tokio::sync::watch;
|
||||||
use ts_rs::TS;
|
use ts_rs::TS;
|
||||||
|
use crate::error::Error::InvalidSyncDirectory;
|
||||||
|
|
||||||
#[command]
|
#[command]
|
||||||
pub async fn calculate<R: Runtime>(
|
pub async fn calculate<R: Runtime>(
|
||||||
@@ -19,6 +20,10 @@ pub async fn calculate<R: Runtime>(
|
|||||||
workspace_id: &str,
|
workspace_id: &str,
|
||||||
sync_dir: &Path,
|
sync_dir: &Path,
|
||||||
) -> Result<Vec<SyncOp>> {
|
) -> 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 db_candidates = get_db_candidates(&app_handle, workspace_id, sync_dir)?;
|
||||||
let fs_candidates = get_fs_candidates(sync_dir)?
|
let fs_candidates = get_fs_candidates(sync_dir)?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
|||||||
@@ -25,6 +25,9 @@ pub enum Error {
|
|||||||
#[error("Invalid sync file: {0}")]
|
#[error("Invalid sync file: {0}")]
|
||||||
InvalidSyncFile(String),
|
InvalidSyncFile(String),
|
||||||
|
|
||||||
|
#[error("Invalid sync directory: {0}")]
|
||||||
|
InvalidSyncDirectory(String),
|
||||||
|
|
||||||
#[error("Watch error: {0}")]
|
#[error("Watch error: {0}")]
|
||||||
NotifyError(#[from] notify::Error),
|
NotifyError(#[from] notify::Error),
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user