π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
fix(rust): Validate account exists before update/delete
Manav Rathi034e789242b0
diff --git a/rust/src/commands/account.rs b/rust/src/commands/account.rsindex 4bea1c28db..c32084251b 100644--- a/rust/src/commands/account.rs+++ b/rust/src/commands/account.rs@@ -315,6 +315,14 @@ async fn update_account(storage: &Storage, email: &str, dir: &str, app_str: &str}};+ // Check if account exists+ if storage.accounts().get(email, app)?.is_none() {+ return Err(crate::models::error::Error::NotFound(format!(+ "Account not found: {} (app: {:?})",+ email, app+ )));+ }+// Validate export directorylet export_path = PathBuf::from(dir);if !export_path.exists() {diff --git a/rust/src/storage/account.rs b/rust/src/storage/account.rsindex c372a97a9f..991376d8f7 100644--- a/rust/src/storage/account.rs+++ b/rust/src/storage/account.rs@@ -71,21 +71,36 @@ impl<'a> AccountStore<'a> {pub fn update_export_dir(&self, email: &str, app: App, export_dir: &str) -> Result<()> {let now = current_timestamp();- self.conn.execute(+ let rows_affected = self.conn.execute("UPDATE accounts SET export_dir = ?1, updated_at = ?2WHERE email = ?3 AND app = ?4",params![export_dir, now, email, format!("{app:?}").to_lowercase()],)?;+ if rows_affected == 0 {+ return Err(crate::Error::NotFound(format!(+ "Account not found: {} (app: {:?})",+ email, app+ )));+ }+Ok(())}/// Delete an accountpub fn delete(&self, user_id: i64, app: App) -> Result<()> {- self.conn.execute(+ let rows_affected = self.conn.execute("DELETE FROM accounts WHERE user_id = ?1 AND app = ?2",params![user_id, format!("{app:?}").to_lowercase()],)?;++ if rows_affected == 0 {+ return Err(crate::Error::NotFound(format!(+ "Account not found: user_id={} (app: {:?})",+ user_id, app+ )));+ }+Ok(())}