Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

refactor(rust): Remove backward compatibility code

Manav Rathie53ddb8b51a0
diff --git a/rust/src/commands/account.rs b/rust/src/commands/account.rs
index bcf8b60ff4..cedad9f0b1 100644
--- a/rust/src/commands/account.rs
+++ b/rust/src/commands/account.rs
@@ -267,9 +267,8 @@ async fn add_account(
// Create account
let account = Account {
- id: 0, // Will be set by database
- email: email.clone(),
user_id: auth_response.id,
+ email: email.clone(),
app,
endpoint: endpoint.clone(),
export_dir: Some(export_dir.clone()),
diff --git a/rust/src/commands/sync.rs b/rust/src/commands/sync.rs
index b36a37b73a..d5a8170368 100644
--- a/rust/src/commands/sync.rs
+++ b/rust/src/commands/sync.rs
@@ -84,7 +84,7 @@ async fn sync_account(
// Clear sync state if full sync requested
if full_sync {
println!("Performing full sync (clearing existing sync state)...");
- storage.sync().clear_sync_state(account.id)?;
+ storage.sync().clear_sync_state(account.user_id)?;
}
// Create sync engine (need to create new instances for ownership)
@@ -109,7 +109,7 @@ async fn sync_account(
// Download files if not metadata-only
if !metadata_only {
// Get pending downloads
- let pending_files = storage.sync().get_pending_downloads(account.id)?;
+ let pending_files = storage.sync().get_pending_downloads(account.user_id)?;
if !pending_files.is_empty() {
println!("\nπŸ“₯ Found {} files to download", pending_files.len());
@@ -159,7 +159,7 @@ async fn sync_account(
// File already exists, mark it as synced in database
storage
.sync()
- .update_file_local_path(file.id, path.to_str().unwrap_or(""))?;
+ .mark_file_synced(file.id, Some(path.to_str().unwrap_or("")))?;
already_synced += 1;
} else {
to_download.push((file, path));
@@ -182,7 +182,7 @@ async fn sync_account(
for (file, path) in &download_stats.successful_downloads {
storage
.sync()
- .update_file_local_path(file.id, path.to_str().unwrap_or(""))?;
+ .mark_file_synced(file.id, Some(path.to_str().unwrap_or("")))?;
}
println!(
diff --git a/rust/src/models/account.rs b/rust/src/models/account.rs
index 8740af7c38..4e5031b7a4 100644
--- a/rust/src/models/account.rs
+++ b/rust/src/models/account.rs
@@ -6,9 +6,8 @@ use zeroize::Zeroize;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Account {
- pub id: i64,
- pub email: String,
pub user_id: i64,
+ pub email: String,
pub app: App,
pub endpoint: String,
pub export_dir: Option<String>,
diff --git a/rust/src/storage/account.rs b/rust/src/storage/account.rs
index 0f1eab7211..c372a97a9f 100644
--- a/rust/src/storage/account.rs
+++ b/rust/src/storage/account.rs
@@ -143,7 +143,6 @@ fn row_to_account(row: &Row) -> rusqlite::Result<Account> {
};
Ok(Account {
- id: 0, // Not used anymore, but kept for compatibility
user_id: row.get(0)?,
app,
email: row.get(2)?,
diff --git a/rust/src/storage/sync.rs b/rust/src/storage/sync.rs
index 72c6552641..fcc65f6c19 100644
--- a/rust/src/storage/sync.rs
+++ b/rust/src/storage/sync.rs
@@ -302,9 +302,4 @@ impl<'a> SyncStore<'a> {
Ok(())
}
-
- /// Update file local path (legacy method - consider using mark_file_synced instead)
- pub fn update_file_local_path(&self, file_id: i64, local_path: &str) -> Result<()> {
- self.mark_file_synced(file_id, Some(local_path))
- }
}
diff --git a/rust/src/sync/engine.rs b/rust/src/sync/engine.rs
index 278aac568f..ef3d04ad45 100644
--- a/rust/src/sync/engine.rs
+++ b/rust/src/sync/engine.rs
@@ -48,7 +48,7 @@ impl SyncEngine {
// Get last sync time for collections
let last_sync = sync_store
- .get_last_sync(self.account.id, "collections")?
+ .get_last_sync(self.account.user_id, "collections")?
.unwrap_or(0);
let api = ApiMethods::new(&self.api_client);
@@ -122,7 +122,7 @@ impl SyncEngine {
let mut result = SyncResult::default();
// Get all collections for this account
- let collections = sync_store.get_collections(self.account.id)?;
+ let collections = sync_store.get_collections(self.account.user_id)?;
// Sync files for each collection
for collection in collections {
@@ -139,7 +139,7 @@ impl SyncEngine {
// Get last sync time for this collection's files
let mut last_sync = sync_store
.get_last_sync(
- self.account.id,
+ self.account.user_id,
&format!("collection_{}_files", collection.id),
)?
.unwrap_or(0);
@@ -215,7 +215,7 @@ impl SyncEngine {
// Update sync state after each batch for this collection
sync_store.update_sync_state(
- self.account.id,
+ self.account.user_id,
&format!("collection_{}_files", collection.id),
last_sync,
)?;
@@ -236,11 +236,11 @@ impl SyncEngine {
// Get all non-deleted files for this account
// Note: We'll need to check all collections for this account
- let collections = sync_store.get_collections(self.account.id)?;
+ let collections = sync_store.get_collections(self.account.user_id)?;
let mut all_files = Vec::new();
for collection in collections {
- let files = sync_store.get_files_by_collection(self.account.id, collection.id)?;
+ let files = sync_store.get_files_by_collection(self.account.user_id, collection.id)?;
all_files.extend(files);
}
@@ -254,7 +254,7 @@ impl SyncEngine {
/// Get collections for decryption keys
pub async fn get_collections(&self) -> Result<Vec<crate::models::collection::Collection>> {
let sync_store = self.storage.sync();
- sync_store.get_collections(self.account.id)
+ sync_store.get_collections(self.account.user_id)
}
}