Skip to content

armgit / ente

Public Imported from GitHub
0

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

Use load for usearch index

laurenspriem972be1f41ebc
diff --git a/mobile/apps/photos/rust/src/api/usearch_api.rs b/mobile/apps/photos/rust/src/api/usearch_api.rs
index 395f93b04d..b2c77f0fd3 100644
--- a/mobile/apps/photos/rust/src/api/usearch_api.rs
+++ b/mobile/apps/photos/rust/src/api/usearch_api.rs
@@ -32,8 +32,11 @@ impl VectorDB {
if file_exists {
println!("Loading index from disk.");
- // Use view to not load the index into memory. https://docs.rs/usearch/latest/usearch/struct.Index.html#method.view
- db.index.view(file_path).expect("Failed to load index");
+ // Must use load() instead of view() because:
+ // - view() creates a read-only memory-mapped view (immutable)
+ // - load() loads the index into RAM for read/write operations (mutable)
+ // Using view() causes "Can't add to an immutable index" error
+ db.index.load(file_path).expect("Failed to load index");
} else {
println!("Creating new index.");
db.save_index();