diff --git a/data/users/momentry.sqlite b/data/users/momentry.sqlite index f44a1cc..2720505 100644 Binary files a/data/users/momentry.sqlite and b/data/users/momentry.sqlite differ diff --git a/data/users/warren.sqlite b/data/users/warren.sqlite index 603289b..ca78efd 100644 Binary files a/data/users/warren.sqlite and b/data/users/warren.sqlite differ diff --git a/src/server.rs b/src/server.rs index 584b554..2242eb9 100644 --- a/src/server.rs +++ b/src/server.rs @@ -827,13 +827,7 @@ async fn upload_file( hasher.update(input.as_bytes()); let hash = hasher.finalize(); let hex = format!("{:x}", hash); - let file_uuid = hex.chars().take(32).collect::(); - - // Clone values for database save (before move) - let file_uuid_clone = file_uuid.clone(); - let file_hash_clone = file_hash.clone(); - let filename_clone = filename.clone(); - let file_path_clone = file_path.clone(); + let file_uuid = hex[0..32].to_string(); // Save to database (user-specific SQLite) let db_path = crate::filetree::FileTree::user_db_path(&user_id); @@ -850,8 +844,8 @@ async fn upload_file( "INSERT INTO file_registry (file_uuid, sha256, file_size, mime_type, registered_at) VALUES (?1, ?2, ?3, ?4, ?5)", rusqlite::params![ - &file_uuid,file_uuid_clonefile_uuid_clone, - &file_hash,file_hash_clonefile_hash_clone, + &file_uuid, + &file_hash, file_size, "", // mime_type (optional) now @@ -862,21 +856,20 @@ async fn upload_file( conn.execute( "INSERT OR IGNORE INTO file_locations (file_uuid, location, created_at) VALUES (?1, ?2, ?3)", - rusqlite::params![&file_uuid,file_uuid_clonefile_uuid_clone, &file_path,file_path_clonefile_path_clone, now], + rusqlite::params![&file_uuid, &file_path, now], )?; // Create file node - let uuid_str = uuid::Uuid::new_v4().to_string().replace('-', ""); - let node_id = format!("node-{}", uuid_str.chars().take(8).collect::()); + let node_id = format!("node-{}", uuid::Uuid::new_v4().to_string().replace('-', "")[0..8]); conn.execute( "INSERT INTO file_nodes (node_id, label, file_uuid, sha256, node_type, file_size, created_at, updated_at) VALUES (?1, ?2, ?3, ?4, 'file', ?5, ?6, ?7)", rusqlite::params![ &node_id, - &filename,filename_clonefilename_clone, - &file_uuid,file_uuid_clonefile_uuid_clone, - &file_hash,file_hash_clonefile_hash_clone, + &filename, + &file_uuid, + &file_hash, file_size, now, now @@ -1157,7 +1150,7 @@ async fn stream_file(Path(file_uuid): Path) -> impl IntoResponse { // Document conversion: Phase 1 (textutil/unzip) → Phase 2 (soffice/qlmanage) if crate::filetree::convert::is_document_ext(&ext) { if let Some((cached, mime)) = - crate::filetree::convert::get_cached_preview(&file_uuid,file_uuid_clonefile_uuid_clone, &ext) + crate::filetree::convert::get_cached_preview(&file_uuid, &ext) { return Ok((cached.to_string_lossy().to_string(), mime.to_string())); } @@ -1302,7 +1295,7 @@ async fn add_file_location( let result = tokio::task::spawn_blocking(move || -> anyhow::Result { let conn = FileTree::open_user_db("demo")?; - FileTree::add_location(&conn, &file_uuid,file_uuid_clonefile_uuid_clone, &location, label.as_deref())?; + FileTree::add_location(&conn, &file_uuid, &location, label.as_deref())?; Ok(serde_json::json!({"ok": true})) }) .await;