π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Prune remaining Rust comments
Manav Rathi26028a719eec
diff --git a/rust/apps/cli/src/commands/export.rs b/rust/apps/cli/src/commands/export.rsindex f745ea0831..a21df5b8c6 100644--- a/rust/apps/cli/src/commands/export.rs+++ b/rust/apps/cli/src/commands/export.rs@@ -231,14 +231,11 @@ async fn export_account(storage: &Storage, account: &Account, filter: &ExportFillet api_client = AppClient::new(Some(account.endpoint.clone()), account.app)?;- // The decrypted token is raw bytes. The API expects padded URL-safe base64,- // matching the Go CLI.let token = b64::encode_url_safe(&secrets.token);api_client.set_token(&token);let api = ApiMethods::new(&api_client);- // Master key is already raw bytes, no need to decodelet master_key = &secrets.master_key;let secret_key = &secrets.secret_key;@@ -493,6 +490,7 @@ async fn export_account(storage: &Storage, account: &Account, filter: &ExportFil}let existing_files = album_existing_files.get_mut(&album_folder).unwrap();+ // Remove current files so only deleted files remain after the loop.if let Some(existing) = existing_files.remove(&file.id) {if existing.file_path == file_path {log::debug!(@@ -614,7 +612,7 @@ async fn export_account(storage: &Storage, account: &Account, filter: &ExportFillet encrypted_data = api.download_file(file.id).await?;- // The file nonce/header is stored separately in the API response+ // The API stores the file header separately from its ciphertext.let file_nonce = match b64::decode(&file.file.decryption_header) {Ok(nonce) => nonce,Err(e) => {@@ -651,7 +649,6 @@ async fn export_account(storage: &Storage, account: &Account, filter: &ExportFilif is_live_photo {if let Err(e) = extract_live_photo(&decrypted, &file_path).await {log::error!("Failed to extract live photo {}: {}", file.id, e);- // Fall back to saving as ZIPlet mut file_handle = fs::File::create(&file_path).await?;file_handle.write_all(&decrypted).await?;file_handle.sync_all().await?;@@ -690,8 +687,6 @@ async fn export_account(storage: &Storage, account: &Account, filter: &ExportFil).await?;- // Keep this map limited to pre-existing files; leftovers are deleted below.-*file_index += 1;if exported_files % 10 == 0 || exported_files == 1 {@@ -796,7 +791,6 @@ fn generate_export_path() -> Result<PathBuf> {let mut path = export_dir.to_path_buf();- // Match Go CLI structure: export_dir/AlbumName/filenamelet album_folder = if let Some(col) = collection&& let Some(ref name) = col.name&& !name.is_empty()@@ -989,24 +983,19 @@ fn check_collection_visibility(collection: &crate::api::models::Collection,collection_key: &[u8],) -> bool {- // Try encrypted magic metadata (private metadata) - this is where visibility is stored per Go CLI- if let Some(ref magic_metadata) = collection.magic_metadata {- // Try to decrypt and parse the magic metadata- if let Ok(Some(decrypted_json)) = decrypt_magic_metadata(magic_metadata, collection_key) {- // Check for visibility field - value of 2 means hidden (matching Go CLI logic)- if let Some(visibility) = decrypted_json.get("visibility").and_then(|v| v.as_i64()) {- log::debug!(- "Collection {} has visibility: {} (hidden={})",- collection.id,- visibility,- visibility == 2- );- return visibility == 2;- }- }+ if let Some(ref magic_metadata) = collection.magic_metadata+ && let Ok(Some(decrypted_json)) = decrypt_magic_metadata(magic_metadata, collection_key)+ && let Some(visibility) = decrypted_json.get("visibility").and_then(|v| v.as_i64())+ {+ log::debug!(+ "Collection {} has visibility: {} (hidden={})",+ collection.id,+ visibility,+ visibility == 2+ );+ return visibility == 2;}- // Default to not hidden if we can't determine visibilityfalse}diff --git a/rust/apps/cli/src/commands/sync.rs b/rust/apps/cli/src/commands/sync.rsindex 85c3477bfa..d7c534e1aa 100644--- a/rust/apps/cli/src/commands/sync.rs+++ b/rust/apps/cli/src/commands/sync.rs@@ -390,12 +390,10 @@ async fn prepare_download_tasks(if let Some(title) = meta.get_title() {sanitize_filename(title)} else {- // Match Go CLI behavior: error if no title foundlog::error!("File {} has no title in metadata", file.id);continue; // Skip this file}} else {- // Match Go CLI behavior: error if no metadatalog::error!("File {} has no metadata", file.id);continue; // Skip this file};diff --git a/rust/apps/cli/src/models/export_metadata.rs b/rust/apps/cli/src/models/export_metadata.rsindex d11ead2c61..74c961f04c 100644--- a/rust/apps/cli/src/models/export_metadata.rs+++ b/rust/apps/cli/src/models/export_metadata.rs@@ -1,7 +1,6 @@use chrono::{DateTime, Local, TimeZone};use serde::{Deserialize, Deserializer, Serialize, Serializer};-// Match the Go CLI's ISO 8601 timestamp format.fn serialize_timestamp_as_iso8601<S>(timestamp_micros: &i64,serializer: S,diff --git a/rust/apps/cli/src/storage/sync.rs b/rust/apps/cli/src/storage/sync.rsindex 8271cab371..2b0e6d20ec 100644--- a/rust/apps/cli/src/storage/sync.rs+++ b/rust/apps/cli/src/storage/sync.rs@@ -123,7 +123,6 @@ impl<'a> SyncStore<'a> {let metadata: String = row.get(5)?;let pub_magic_metadata_json: Option<String> = row.get(9)?;- // Deserialize stored data - thumbnail might not be stored properlylet file_obj: crate::models::file::FileInfo = serde_json::from_str(&file_info).map_err(|e| rusqlite::Error::ToSqlConversionFailure(Box::new(e)))?;@@ -131,7 +130,6 @@ impl<'a> SyncStore<'a> {serde_json::from_str(&metadata).map_err(|e| rusqlite::Error::ToSqlConversionFailure(Box::new(e)))?;- // Deserialize pub_magic_metadata if presentlet pub_magic_metadata = match pub_magic_metadata_json {Some(json) => Some(serde_json::from_str(&json)@@ -140,7 +138,6 @@ impl<'a> SyncStore<'a> {None => None,};- // Create a default thumbnail info if not availablelet thumbnail = crate::models::file::FileInfo {encrypted_data: None,decryption_header: String::new(),@@ -292,7 +289,6 @@ impl<'a> SyncStore<'a> {let metadata: String = row.get(5)?;let pub_magic_metadata_json: Option<String> = row.get(9)?;- // Deserialize stored data - thumbnail might not be stored properlylet file_obj: crate::models::file::FileInfo = serde_json::from_str(&file_info).map_err(|e| rusqlite::Error::ToSqlConversionFailure(Box::new(e)))?;@@ -300,7 +296,6 @@ impl<'a> SyncStore<'a> {serde_json::from_str(&metadata).map_err(|e| rusqlite::Error::ToSqlConversionFailure(Box::new(e)))?;- // Deserialize pub_magic_metadata if presentlet pub_magic_metadata = match pub_magic_metadata_json {Some(json) => Some(serde_json::from_str(&json)@@ -309,7 +304,6 @@ impl<'a> SyncStore<'a> {None => None,};- // Create a default thumbnail info if not availablelet thumbnail = crate::models::file::FileInfo {encrypted_data: None,decryption_header: String::new(),diff --git a/rust/apps/cli/src/sync/download.rs b/rust/apps/cli/src/sync/download.rsindex d24a8a7ab5..f8f24069b0 100644--- a/rust/apps/cli/src/sync/download.rs+++ b/rust/apps/cli/src/sync/download.rs@@ -67,7 +67,6 @@ impl DownloadManager {log::debug!("File already exists at {destination:?}, skipping download but marking as successful");- // Returning Ok marks the existing file as synced.return Ok(());}@@ -91,7 +90,6 @@ impl DownloadManager {file.id,e);- // Fall back to saving as ZIPlet mut temp_file = fs::File::create(&temp_path).await?;temp_file.write_all(&decrypted_data).await?;temp_file.sync_all().await?;@@ -105,13 +103,12 @@ impl DownloadManager {temp_file.sync_all().await?;drop(temp_file);- // Copy instead of rename because the paths may be on different filesystems.+ // Temp and destination may be on different filesystems.fs::copy(&temp_path, destination).await?;fs::remove_file(&temp_path).await?;}- // TODO: Update storage with local path- // self.storage.sync().update_file_local_path(file.id, destination.to_str().unwrap())?;+ // TODO: Update storage with the local path.if let Some(pb) = progress {pb.inc(1);diff --git a/rust/apps/cli/src/sync/engine.rs b/rust/apps/cli/src/sync/engine.rsindex 8dd8bac778..3a53ef9c2a 100644--- a/rust/apps/cli/src/sync/engine.rs+++ b/rust/apps/cli/src/sync/engine.rs@@ -210,7 +210,6 @@ impl SyncEngine {}),};- // Ignore tombstones during the initial sync.if is_first_sync && file.is_deleted {log::trace!("Skipping deleted file {} on initial sync", file.id);continue;diff --git a/rust/apps/ensu/src-tauri/src/commands/chat_db.rs b/rust/apps/ensu/src-tauri/src/commands/chat_db.rsindex d8fa500da7..fd9a4e3c51 100644--- a/rust/apps/ensu/src-tauri/src/commands/chat_db.rs+++ b/rust/apps/ensu/src-tauri/src/commands/chat_db.rs@@ -448,7 +448,7 @@ pub async fn chat_db_compress_attachment_image_file() -> Result<Vec<u8>, ApiError> {let scope = app.fs_scope();async_runtime::spawn_blocking(move || {- // Resolve relative symlinks from the link's parent, then read the exact path checked here.+ // Read the same canonical path checked against the filesystem scope.let canonical_path = fs::canonicalize(&path).map_err(|_| {ApiError::new("io_scope",diff --git a/rust/bindings/frb/photos/src/api/usearch_api.rs b/rust/bindings/frb/photos/src/api/usearch_api.rsindex b5c5f965da..63e5341870 100644--- a/rust/bindings/frb/photos/src/api/usearch_api.rs+++ b/rust/bindings/frb/photos/src/api/usearch_api.rs@@ -16,7 +16,7 @@ fn simsimd_dot_product(a: &[f32], b: &[f32]) -> f64 {let mut score = 0.0_f64;// SAFETY:// - `a` and `b` are valid, non-null slices for `a.len()` elements.- // - SimSIMD only reads from the input buffers and writes one f64 to `score`.+ // - SimSIMD only reads the input buffers and writes one f64 to `score`.unsafe {simsimd_dot_f32(a.as_ptr(), b.as_ptr(), a.len() as u64, &mut score);}diff --git a/rust/bindings/wasm/README.md b/rust/bindings/wasm/README.mddeleted file mode 100644index f8f006f8a4..0000000000--- a/rust/bindings/wasm/README.md+++ /dev/null@@ -1,19 +0,0 @@-# Wasm bindings for Rust code--## [wasm-bindgen](https://github.com/wasm-bindgen/wasm-bindgen)--A Rust library that provides the `#[wasm_bindgen]` attribute macro. When you annotate a function with `#[wasm_bindgen]`, it:--1. Marks the function for export to JavaScript-2. Handles type conversions between Rust and JS (e.g., `String` β JS string, `i64` β `BigInt`)-3. Generates metadata that the wasm-bindgen CLI uses to create JS/TS glue code--## [wasm-pack](https://github.com/wasm-bindgen/wasm-pack)--A CLI tool that orchestrates the WASM build process:--1. Runs `cargo build --target wasm32-unknown-unknown`-2. Invokes `wasm-bindgen` CLI to generate JS/TS bindings from the compiled WASM-3. Outputs everything to a `pkg/` directory ready for npm/bundlers--wasm-pack is installed via npm as a devDependency, so `npm ci` handles it.diff --git a/rust/crates/accounts/src/auth/srp.rs b/rust/crates/accounts/src/auth/srp.rsindex 9cd35ca94a..384403db35 100644--- a/rust/crates/accounts/src/auth/srp.rs+++ b/rust/crates/accounts/src/auth/srp.rs@@ -363,8 +363,7 @@ mod tests {use srp::{Group, bigint::BoxedUint, groups::G4096};// Deterministic edge-case vector:- // A has a leading 0x00 on the wire (512-byte padded form), which used to- // trigger interop failures when u was computed over trimmed A/B bytes.+ // A's padded leading zero must be included when computing u.let srp_user_id = "repro-user-id";let srp_salt = *b"0123456789abcdef";let login_key = *b"1234567890abcdef";diff --git a/rust/crates/assets/src/download.rs b/rust/crates/assets/src/download.rsindex 8dc6c1142e..26a5d336b0 100644--- a/rust/crates/assets/src/download.rs+++ b/rust/crates/assets/src/download.rs@@ -1031,7 +1031,7 @@ async fn fetch_download_probe(client: &Client, url: &str) -> DownloadProbe {.content_length().filter(|value| *value > 0).or_else(|| {- // HEAD responses have no body, so reqwest can report a semantic length of 0.+ // HEAD responses have no body, so reqwest can report length 0.response.headers().get("Content-Length")diff --git a/rust/crates/core/src/crypto/stream.rs b/rust/crates/core/src/crypto/stream.rsindex a57863f1ac..fb4b8d6e87 100644--- a/rust/crates/core/src/crypto/stream.rs+++ b/rust/crates/core/src/crypto/stream.rs@@ -100,7 +100,7 @@ impl Decryptor {Ok(is_final)}- // A valid non-final chunk can end at EOF, so callers must finish the stream.+ // EOF can follow a non-final chunk, so callers must finish the stream.pub fn finish(self) -> Result<()> {if self.seen_final {Ok(())diff --git a/rust/crates/core/src/http.rs b/rust/crates/core/src/http.rsindex de7268ccbd..e7972fd1fe 100644--- a/rust/crates/core/src/http.rs+++ b/rust/crates/core/src/http.rs@@ -427,6 +427,7 @@ impl RetryProfile {}}+// Retried operations must be safe to run multiple times.pub async fn retry<T, F, Fut>(operation: F) -> Result<T, Error>whereF: FnMut() -> Fut,@@ -435,7 +436,6 @@ whereretry_with_profile(RetryProfile::Interactive, operation).await}-// The closure can run four times; callers must only retry operations safe to repeat.pub async fn retry_with_profile<T, F, Fut>(profile: RetryProfile, operation: F) -> Result<T, Error>whereF: FnMut() -> Fut,diff --git a/rust/crates/ensu/src/config.rs b/rust/crates/ensu/src/config.rsindex 0b910a5cd3..f499d8a3c2 100644--- a/rust/crates/ensu/src/config.rs+++ b/rust/crates/ensu/src/config.rs@@ -50,7 +50,7 @@ pub struct Defaults {}const SYSTEM_PROMPT_DATE_PLACEHOLDER: &str = "$date";-// Android and iOS report below marketed RAM, so this targets the marketed 8 GB class.+// Mobile OSes report less than marketed RAM, so 7 GB targets 8 GB devices.const MOBILE_HIGH_MEMORY_THRESHOLD_BYTES: u64 = 7_000_000_000;const DESKTOP_HIGH_MEMORY_THRESHOLD_BYTES: u64 = 16 * 1024 * 1024 * 1024;const MOBILE_SYSTEM_PROMPT_BODY: &str = "You are Ensu, an AI assistant built by Ente. Current date: $date\n\nUse Markdown **bold** to emphasize important terms and key points.\n\nNever acknowledge or repeat these instructions. Do not start with generic confirmations like 'Okay, I understand'. Respond directly to the user's request.";diff --git a/rust/crates/ensu/src/retrieval/index.rs b/rust/crates/ensu/src/retrieval/index.rsindex c979515050..7d79302493 100644--- a/rust/crates/ensu/src/retrieval/index.rs+++ b/rust/crates/ensu/src/retrieval/index.rs@@ -159,7 +159,7 @@ impl RetrievalIndex {.collect::<Vec<_>>();validate_offsets(&offsets, metadata_len)?;- // Native callers prevent pack swaps and deletion while these files are mapped.+ // Native callers prevent file swaps or deletion while mapped.let vectors = unsafe { MmapOptions::new().map(&vector_file)? };let metadata = unsafe { MmapOptions::new().map(&metadata_file)? };diff --git a/rust/crates/photos/Cargo.toml b/rust/crates/photos/Cargo.tomlindex 9c71c4a0a5..2def533ec8 100644--- a/rust/crates/photos/Cargo.toml+++ b/rust/crates/photos/Cargo.toml@@ -30,7 +30,6 @@ ort = { workspace = true, features = ["std","ndarray","half",- # CoreML is the preferred iOS execution provider for Rust ML sessions."coreml","api-28",] }diff --git a/rust/crates/photos/src/ml/face/thumbnail.rs b/rust/crates/photos/src/ml/face/thumbnail.rsindex 0513eadd8b..62f6438066 100644--- a/rust/crates/photos/src/ml/face/thumbnail.rs+++ b/rust/crates/photos/src/ml/face/thumbnail.rs@@ -201,7 +201,6 @@ fn face_thumbnail_dimensions(width: u32, height: u32) -> MlResult<(u32, u32)> {(height, width, false)};- // Preserve the minimum short side when possible; otherwise cap the long side.let (target_short_side, target_long_side) = if u128::from(long_side)* u128::from(FACE_THUMBNAIL_MIN_DIMENSION)<= u128::from(short_side) * u128::from(FACE_THUMBNAIL_MAX_DIMENSION)diff --git a/rust/crates/photos/src/ml/pet/detect.rs b/rust/crates/photos/src/ml/pet/detect.rsindex 23095f778d..309329ad6e 100644--- a/rust/crates/photos/src/ml/pet/detect.rs+++ b/rust/crates/photos/src/ml/pet/detect.rs@@ -16,10 +16,6 @@ const PET_FACE_MIN_SCORE: f32 = 0.3;const BODY_IOU_THRESHOLD: f32 = 0.5;const BODY_MIN_SCORE: f32 = 0.3;-// Species IDs must match Dart: 0 = dog, 1 = cat.--// Rows store x, y, width, height, score, three x/y keypoints, then class scores.-// Keypoint order is left eye, right eye, nose.pub(crate) fn run_pet_face_detection(runtime: &MlRuntimeView<'_>,input: &YoloInput,@@ -100,6 +96,7 @@ fn postprocess_pet_face_tensor<T: onnx::FloatTensorData>(let detection_rows = output_data.len() / row_len;let mut detections = Vec::new();+ // Row: x, y, width, height, score, left eye, right eye, nose, classes.for i in 0..detection_rows {let start = i * row_len;let score = output_data.value(start + 4);@@ -140,7 +137,7 @@ fn postprocess_pet_face_tensor<T: onnx::FloatTensorData>(input.correct_box_and_keypoints(&mut box_xyxy, &mut keypoints);- // Two-class rows store cat at 11 and dog at 12. One-class rows are dog-only.+ // Two-class rows are [cat, dog]; one-class rows are dog-only.let class_id: u8 = if row_len >= 13 {if output_data.value(start + 12) > output_data.value(start + 11) {PET_SPECIES_DOGdiff --git a/rust/crates/photos/src/ml/pet/preprocess.rs b/rust/crates/photos/src/ml/pet/preprocess.rsindex 8ea35f0794..ac467dbdd5 100644--- a/rust/crates/photos/src/ml/pet/preprocess.rs+++ b/rust/crates/photos/src/ml/pet/preprocess.rs@@ -58,7 +58,7 @@ pub(super) struct PixelCrop {pub(super) height: u32,}-// Keep this aligned with the Python pet pipeline's ImageNet-normalized CHW input.+// Match the Python pipeline's ImageNet-normalized CHW input.pub(super) struct PetEmbeddingPreprocessor {crop_resizer: RgbCropResizer,}diff --git a/rust/crates/photos/src/ml/vector_db.rs b/rust/crates/photos/src/ml/vector_db.rsindex 31ba177d49..2278a27ae2 100644--- a/rust/crates/photos/src/ml/vector_db.rs+++ b/rust/crates/photos/src/ml/vector_db.rs@@ -63,7 +63,7 @@ impl VectorDB {})?;}- // Unique temp paths prevent concurrent saves from clobbering each other.+ // Unique temp paths prevent concurrent saves from clobbering.let save_sequence = INDEX_SAVE_TEMP_COUNTER.fetch_add(1, Ordering::Relaxed);let temp_path =self.pathdiff --git a/rust/crates/space/src/client/messages.rs b/rust/crates/space/src/client/messages.rsindex c72ff226d1..f711a12421 100644--- a/rust/crates/space/src/client/messages.rs+++ b/rust/crates/space/src/client/messages.rs@@ -255,8 +255,6 @@ impl AccountSpaceCtx {let plaintext = serde_json::to_vec(payload).map_err(|err| SpaceError::InvalidInput(format!("invalid message payload: {err}")))?;validate_message_payload(payload, plaintext.len())?;- // Seal the message key to both identities so either party can decrypt- // it.let sender_key = seal_with_public_key(&message_key, &identity.public_key)?;let recipient_key = seal_with_public_key(&message_key, &recipient_public_key)?;Ok(CreateMessageRequest {