diff --git a/src-tauri/yaak-sync/src/sync.rs b/src-tauri/yaak-sync/src/sync.rs index 3d902273..9d8728ff 100644 --- a/src-tauri/yaak-sync/src/sync.rs +++ b/src-tauri/yaak-sync/src/sync.rs @@ -1,7 +1,7 @@ use crate::error::Result; use crate::models::SyncModel; use chrono::Utc; -use log::{debug, warn}; +use log::{debug, info, warn}; use serde::{Deserialize, Serialize}; use std::collections::HashMap; use std::fmt::{Display, Formatter}; @@ -164,6 +164,13 @@ pub(crate) async fn get_fs_candidates(dir: &Path) -> Result> { let path = dir_entry.path(); let (model, checksum) = match SyncModel::from_file(&path) { + // TODO: Remove this once we have logic to handle environments. This it to clean + // any existing ones from the sync dir that resulted from the 2025.1 betas. + Ok(Some((SyncModel::Environment(e), _))) => { + fs::remove_file(path).await?; + info!("Cleaned up synced environment {}", e.id); + continue; + } Ok(Some(m)) => m, Ok(None) => continue, Err(e) => { @@ -205,9 +212,17 @@ pub(crate) fn compute_sync_ops( let op = match (db_map.get(k), fs_map.get(k)) { (None, None) => return None, // Can never happen (None, Some(fs)) => SyncOp::DbCreate { fs: fs.to_owned() }, - (Some(DbCandidate::Unmodified(model, sync_state)), None) => SyncOp::DbDelete { - model: model.to_owned(), - state: sync_state.to_owned(), + (Some(DbCandidate::Unmodified(model, sync_state)), None) => { + // TODO: Remove this once we have logic to handle environments. This it to + // ignore the cleaning we did above of any environments that were written + // to disk in the 2025.1 betas. + if let SyncModel::Environment(_) = model { + return None; + } + SyncOp::DbDelete { + model: model.to_owned(), + state: sync_state.to_owned(), + } }, (Some(DbCandidate::Modified(model, sync_state)), None) => SyncOp::FsUpdate { model: model.to_owned(), @@ -318,7 +333,7 @@ pub(crate) async fn apply_sync_ops( ); let mut sync_state_ops = Vec::new(); let mut workspaces_to_upsert = Vec::new(); - let mut environments_to_upsert = Vec::new(); + let environments_to_upsert = Vec::new(); let mut folders_to_upsert = Vec::new(); let mut http_requests_to_upsert = Vec::new(); let mut grpc_requests_to_upsert = Vec::new(); @@ -380,11 +395,13 @@ pub(crate) async fn apply_sync_ops( // batch upsert to make foreign keys happy match fs.model { SyncModel::Workspace(m) => workspaces_to_upsert.push(m), - SyncModel::Environment(m) => environments_to_upsert.push(m), SyncModel::Folder(m) => folders_to_upsert.push(m), SyncModel::HttpRequest(m) => http_requests_to_upsert.push(m), SyncModel::GrpcRequest(m) => grpc_requests_to_upsert.push(m), SyncModel::WebsocketRequest(m) => websocket_requests_to_upsert.push(m), + + // TODO: Handle environments in sync + SyncModel::Environment(_) => {} }; SyncStateOp::Create { model_id, @@ -397,11 +414,13 @@ pub(crate) async fn apply_sync_ops( // batch upsert to make foreign keys happy match fs.model { SyncModel::Workspace(m) => workspaces_to_upsert.push(m), - SyncModel::Environment(m) => environments_to_upsert.push(m), SyncModel::Folder(m) => folders_to_upsert.push(m), SyncModel::HttpRequest(m) => http_requests_to_upsert.push(m), SyncModel::GrpcRequest(m) => grpc_requests_to_upsert.push(m), SyncModel::WebsocketRequest(m) => websocket_requests_to_upsert.push(m), + + // TODO: Handle environments in sync + SyncModel::Environment(_) => {} } SyncStateOp::Update { state: state.to_owned(), diff --git a/src-web/components/SyncToFilesystemSetting.tsx b/src-web/components/SyncToFilesystemSetting.tsx index f331d52f..229be7b1 100644 --- a/src-web/components/SyncToFilesystemSetting.tsx +++ b/src-web/components/SyncToFilesystemSetting.tsx @@ -25,6 +25,7 @@ export function SyncToFilesystemSetting({ Sync workspace data to folder as plain text files, ideal for backup and Git collaboration. + Environments are excluded in order to keep your secrets private. {error &&
{error}
} diff --git a/src-web/init/sync.ts b/src-web/init/sync.ts index c3387381..26b45962 100644 --- a/src-web/init/sync.ts +++ b/src-web/init/sync.ts @@ -69,7 +69,7 @@ function isModelRelevant(m: AnyModel) { if ( m.model !== 'workspace' && m.model !== 'folder' && - m.model !== 'environment' && + // m.model !== 'environment' && // Not synced anymore m.model !== 'http_request' && m.model !== 'grpc_request' && m.model !== 'websocket_request'