π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
feat(rust): Remove sync command to match Go CLI interface
Manav Rathi8e3f6e56d285
diff --git a/rust/CLAUDE.md b/rust/CLAUDE.mdindex 930c7e75f9..93d21e8815 100644--- a/rust/CLAUDE.md+++ b/rust/CLAUDE.md@@ -1,6 +1,7 @@# CLAUDE.mdβ οΈ **CRITICAL: Commit & PR Guidelines** β οΈ+**OVERRIDE DEFAULT TEMPLATE - DO NOT USE EMOJI OR "Generated with" TEXT**- Keep messages CONCISE (no walls of text)- Subject line under 72 chars- Brief bullet points only if necessarydiff --git a/rust/src/cli/mod.rs b/rust/src/cli/mod.rsindex 0ac0482a74..8ef6a06758 100644--- a/rust/src/cli/mod.rs+++ b/rust/src/cli/mod.rs@@ -2,7 +2,6 @@ use clap::{Parser, Subcommand};pub mod account;pub mod export;-pub mod sync;pub mod version;#[derive(Parser)]@@ -21,9 +20,6 @@ pub enum Commands {/// Export photos and filesExport(export::ExportCommand),- /// Sync collections and file metadata- Sync(sync::SyncCommand),-/// Print version informationVersion,}diff --git a/rust/src/cli/sync.rs b/rust/src/cli/sync.rsdeleted file mode 100644index 547ea31605..0000000000--- a/rust/src/cli/sync.rs+++ /dev/null@@ -1,16 +0,0 @@-use clap::Args;--#[derive(Args)]-pub struct SyncCommand {- /// Email of the account to sync (optional, syncs all if not specified)- #[arg(long)]- pub account: Option<String>,-- /// Only sync metadata, don't download files- #[arg(long)]- pub metadata_only: bool,-- /// Force full sync instead of incremental- #[arg(long)]- pub full: bool,-}diff --git a/rust/src/commands/export.rs b/rust/src/commands/export.rsindex 5bf8f17382..0cb1ce1401 100644--- a/rust/src/commands/export.rs+++ b/rust/src/commands/export.rs@@ -4,6 +4,7 @@ use crate::api::methods::ApiMethods;use crate::crypto::{decrypt_file_data, decrypt_stream, init as crypto_init, secret_box_open};use crate::models::{account::Account, filter::ExportFilter, metadata::FileMetadata};use crate::storage::Storage;+use crate::sync::SyncEngine;use base64::Engine;use std::collections::HashMap;use std::io::Cursor;@@ -50,6 +51,15 @@ pub async fn run_export(account_email: Option<String>, filter: ExportFilter) ->for account in accounts {println!("\n=== Exporting account: {} ===", account.email);+ // First sync the account (like Go implementation does)+ println!("Syncing account data...");+ if let Err(e) = sync_account_before_export(&storage, &account).await {+ log::error!("Failed to sync account {}: {}", account.email, e);+ println!("β Sync failed: {e}");+ continue;+ }+ println!("β Sync completed!");+if let Err(e) = export_account(&storage, &account, &filter).await {log::error!("Failed to export account {}: {}", account.email, e);println!("β Export failed: {e}");@@ -61,6 +71,43 @@ pub async fn run_export(account_email: Option<String>, filter: ExportFilter) ->Ok(())}+async fn sync_account_before_export(storage: &Storage, account: &Account) -> Result<()> {+ // Get stored secrets+ let secrets = storage+ .accounts()+ .get_secrets(account.user_id, account.app)?+ .ok_or_else(|| crate::Error::NotFound("Account secrets not found".into()))?;++ // Create API client with account's endpoint+ let api_client = ApiClient::new(Some(account.endpoint.clone()))?;++ // Store token for this account+ let token = base64::engine::general_purpose::URL_SAFE.encode(&secrets.token);+ api_client.add_token(&account.email, &token);++ // Get the database path to create a new Storage instance+ let db_path = storage+ .db_path()+ .ok_or_else(|| crate::Error::Generic("Database path not available".into()))?;++ // Create new Storage instance for sync engine (needed for ownership)+ let sync_storage = Storage::new(db_path)?;++ // Create sync engine+ let sync_engine = SyncEngine::new(api_client, sync_storage, account.clone());++ // Run sync for this account+ let stats = sync_engine.sync().await?;++ log::info!(+ "Sync completed: {} new collections, {} new files",+ stats.collections.new,+ stats.files.new+ );++ Ok(())+}+async fn export_account(storage: &Storage, account: &Account, filter: &ExportFilter) -> Result<()> {// Get export directorylet export_dir = accountdiff --git a/rust/src/commands/mod.rs b/rust/src/commands/mod.rsindex aee6f7e970..9c034b0875 100644--- a/rust/src/commands/mod.rs+++ b/rust/src/commands/mod.rs@@ -1,5 +1,4 @@pub mod account;pub mod export;-pub mod sync;pub use account::handle_account_command;diff --git a/rust/src/main.rs b/rust/src/main.rsindex 7bff121e87..e23795266e 100644--- a/rust/src/main.rs+++ b/rust/src/main.rs@@ -42,10 +42,6 @@ async fn main() -> Result<()> {commands::export::run_export(export_cmd.account, filter).await?;}- Commands::Sync(sync_cmd) => {- commands::sync::run_sync(sync_cmd.account, sync_cmd.metadata_only, sync_cmd.full)- .await?;- }}Ok(())