diff --git a/Cargo.lock b/Cargo.lock index c238532..e7e68a2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1527,9 +1527,9 @@ checksum = "3a3076410a55c90011c298b04d0cfa770b00fa04e1e3c97d3f6c9de105a03844" [[package]] name = "fjall" -version = "3.1.2" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a9530ff159bc3ad3a15da746da0f6e95375c2ac64708cbb85ec1ebd26761a84" +checksum = "fdf46551c9abc5fb0e0d540da36c875197285af2a29833892d7d3434b8617343" dependencies = [ "byteorder-lite", "byteview", @@ -2737,9 +2737,9 @@ checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154" [[package]] name = "lsm-tree" -version = "3.1.2" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d67f95fd716870329c30aaeedf87f23d426564e6ce46efa045a91444faf2a19" +checksum = "f38ed727e0965f218f4e419231b9ecacc1db8fb5066cf1df0d2bafeef88459d4" dependencies = [ "byteorder-lite", "bytes 1.11.1", diff --git a/Cargo.toml b/Cargo.toml index 38dee68..28e189b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -122,7 +122,7 @@ rcgen = "0.14.7" rustls-pemfile = "2.2.0" blake3 = "1.8.4" uuid = { version = "1.23.0", features = ["v4", "serde"] } -fjall = { version = "3.1.2", features = ["lz4", "metrics", "bytes_1"] } +fjall = { version = "3.1.3", features = ["lz4", "metrics", "bytes_1"] } tantivy = { version = "0.26.0", features = ["zstd-compression"] } [dev-dependencies] #bincode = "1.3.3" diff --git a/src/modules/store/storage.rs b/src/modules/store/storage.rs index 7708676..7fa22ae 100644 --- a/src/modules/store/storage.rs +++ b/src/modules/store/storage.rs @@ -57,18 +57,17 @@ impl BlobManager { fn process_detached_email( eml: DetachedEmail, - store: &Database, email_ks: &Keyspace, attach_ks: &Keyspace, ) { let (email_hash, email_data) = eml.email; - let mut batch = store.batch(); - let mut needs_commit = false; + match email_ks.contains_key(&email_hash) { Ok(false) => { - batch.insert(email_ks, email_hash.as_bytes(), email_data); - needs_commit = true; + if let Err(e) = email_ks.insert(email_hash, email_data) { + tracing::error!("CRITICAL: Failed to insert email: {:?}", e); + } } Err(e) => tracing::error!("Fjall email_ks error: {:?}", e), _ => {} @@ -78,29 +77,27 @@ impl BlobManager { for (a_hash, a_data) in attachments { match attach_ks.contains_key(&a_hash) { Ok(false) => { - batch.insert(attach_ks, a_hash.as_bytes(), a_data); - needs_commit = true; + if let Err(e) = attach_ks.insert(a_hash, a_data) { + tracing::error!("CRITICAL: Failed to insert attachment: {:?}", e); + } } Err(e) => tracing::error!("Fjall attach_ks error: {:?}", e), _ => {} } } } - - if needs_commit { - if let Err(e) = batch.commit() { - tracing::error!("Fjall Batch Commit Error: {:?}", e); - } - } } pub fn new() -> Self { let db = Database::builder(&DATA_DIR_MANAGER.eml_dir) .cache_size(64 * 1024 * 1024) .max_cached_files(Some(400)) - .max_journaling_size(256 * 1024 * 1024) + .journal_compression(CompressionType::None) + .max_journaling_size(64 * 1024 * 1024) .open() .expect("Failed to initialize Fjall database: Check if the directory exists and has write permissions."); + + let email_keyspace = db .keyspace("email", || { KeyspaceCreateOptions::default() @@ -111,15 +108,15 @@ impl BlobManager { ) .with_kv_separation(Some( KvSeparationOptions::default() - .separation_threshold(0) + .separation_threshold(1024) .compression(CompressionType::Lz4) - .file_target_size(128 * 1024 * 1024) + .file_target_size(512 * 1024 * 1024) .staleness_threshold(0.5) .age_cutoff(0.6), )) }) .expect("Failed to open 'email' keyspace: The partition metadata might be corrupted or inaccessible."); - + let attachments_keyspace = db .keyspace("attachments", || { KeyspaceCreateOptions::default() @@ -129,19 +126,18 @@ impl BlobManager { ) .with_kv_separation(Some( KvSeparationOptions::default() - .separation_threshold(0) + .separation_threshold(1024) .compression(CompressionType::Lz4) - .file_target_size(256 * 1024 * 1024) + .file_target_size(512 * 1024 * 1024) .staleness_threshold(0.5) .age_cutoff(0.6), )) .max_memtable_size(16 * 1024 * 1024) }) .expect("Failed to open 'attachments' keyspace: Check disk space for blob storage initialization."); - + let (sender, mut receiver) = mpsc::channel::(100); - let store = db.clone(); let email_ks = email_keyspace.clone(); let attach_ks = attachments_keyspace.clone(); let handler = task::spawn(async move { @@ -151,9 +147,9 @@ impl BlobManager { res = receiver.recv() => { match res { Some(eml) => { - Self::process_detached_email(eml, &store, &email_ks, &attach_ks); + Self::process_detached_email(eml, &email_ks, &attach_ks); while let Ok(next_eml) = receiver.try_recv() { - Self::process_detached_email(next_eml, &store, &email_ks, &attach_ks); + Self::process_detached_email(next_eml, &email_ks, &attach_ks); } } None => { @@ -171,7 +167,7 @@ impl BlobManager { ); while let Some(eml) = receiver.recv().await { - Self::process_detached_email(eml, &store, &email_ks, &attach_ks); + Self::process_detached_email(eml, &email_ks, &attach_ks); } tracing::info!("BlobManager: All remaining tasks processed. Closing Fjall."); diff --git a/web/src/features/settings/profile/profile-form.tsx b/web/src/features/settings/profile/profile-form.tsx index 3befb51..52bbd4a 100644 --- a/web/src/features/settings/profile/profile-form.tsx +++ b/web/src/features/settings/profile/profile-form.tsx @@ -290,7 +290,7 @@ export function UserProfileForm({ user }: UserProfileFormProps) { {email.charAt(0).toUpperCase()}
- + {email}