修复数据库字段名称问题(进行中)
问题: - file_registry表没有sha256字段 - file_locations表使用added_at而非created_at 修复: - 将sha256插入到file_nodes表而非file_registry - 将created_at改为added_at(多处) 状态:编译中(还有变量名问题待修复) 已验证功能: - ZIP自动解压成功 ✅ - FormatDetector检测成功 ✅ - 提取文件完整性 ✅ - 文件解压到extracted目录 ✅
This commit is contained in:
@@ -1008,11 +1008,28 @@ fn extract_and_register_archive(
|
|||||||
let hex = format!("{:x}", hash);
|
let hex = format!("{:x}", hash);
|
||||||
let file_uuid = hex[0..32].to_string();
|
let file_uuid = hex[0..32].to_string();
|
||||||
|
|
||||||
// Register file
|
// Register file (file_registry table)
|
||||||
conn.execute(
|
conn.execute(
|
||||||
"INSERT INTO file_registry (file_uuid, sha256, file_size, mime_type, registered_at)
|
"INSERT INTO file_registry (file_uuid, original_name, file_size, file_type, registered_at)
|
||||||
VALUES (?1, ?2, ?3, ?4, ?5)",
|
VALUES (?1, ?2, ?3, ?4, ?5)",
|
||||||
rusqlite::params![&file_uuid, &file_hash, file_size, "", now],
|
rusqlite::params![&file_uuid, &filename, file_size, "", now],
|
||||||
|
)?;
|
||||||
|
|
||||||
|
// Add file location
|
||||||
|
conn.execute(
|
||||||
|
"INSERT OR IGNORE INTO file_locations (file_uuid, location, created_at)
|
||||||
|
VALUES (?1, ?2, ?3)",
|
||||||
|
rusqlite::params![&file_uuid, &file_path_str, now],
|
||||||
|
)?;
|
||||||
|
|
||||||
|
// Add file node (with sha256)
|
||||||
|
let uuid_str = uuid::Uuid::new_v4().to_string().replace('-', "");
|
||||||
|
let node_id = format!("node-{}", &uuid_str[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, &file_uuid, &file_hash, file_size, now, now],
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
// Add file location
|
// Add file location
|
||||||
@@ -1211,24 +1228,48 @@ async fn upload_file(
|
|||||||
.unwrap()
|
.unwrap()
|
||||||
.as_secs() as i64;
|
.as_secs() as i64;
|
||||||
|
|
||||||
conn.execute(
|
conn.execute(
|
||||||
"INSERT INTO file_registry (file_uuid, sha256, file_size, mime_type, registered_at)
|
"INSERT INTO file_registry (file_uuid, original_name, file_size, file_type, registered_at)
|
||||||
VALUES (?1, ?2, ?3, ?4, ?5)",
|
VALUES (?1, ?2, ?3, ?4, ?5)",
|
||||||
rusqlite::params![
|
rusqlite::params![
|
||||||
|
&file_uuid_clone,
|
||||||
|
&filename_clone,
|
||||||
|
file_size,
|
||||||
|
"", // file_type (optional)
|
||||||
|
now
|
||||||
|
],
|
||||||
|
)?;
|
||||||
|
|
||||||
|
// Add file location
|
||||||
|
conn.execute(
|
||||||
|
"INSERT OR IGNORE INTO file_locations (file_uuid, location, added_at)
|
||||||
|
VALUES (?1, ?2, ?3)",
|
||||||
|
rusqlite::params![&file_uuid, &file_path_str, now],
|
||||||
|
)?;
|
||||||
|
|
||||||
|
let uuid_str = uuid::Uuid::new_v4().to_string().replace('-', "");
|
||||||
|
let node_id = format!("node-{}", &uuid_str[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_clone,
|
||||||
&file_uuid_clone,
|
&file_uuid_clone,
|
||||||
&file_hash_clone,
|
&file_hash_clone,
|
||||||
file_size,
|
file_size,
|
||||||
"", // mime_type (optional)
|
now,
|
||||||
now
|
now
|
||||||
],
|
],
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
// Add file location
|
// Add file location (file_locations table)
|
||||||
conn.execute(
|
conn.execute(
|
||||||
"INSERT OR IGNORE INTO file_locations (file_uuid, location, created_at)
|
"INSERT OR IGNORE INTO file_locations (file_uuid, location, added_at)
|
||||||
VALUES (?1, ?2, ?3)",
|
VALUES (?1, ?2, ?3)",
|
||||||
rusqlite::params![&file_uuid_clone, &file_path_clone, now],
|
rusqlite::params![&file_uuid_clone, &file_path_clone, now],
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let uuid_str = uuid::Uuid::new_v4().to_string().replace('-', "");
|
let uuid_str = uuid::Uuid::new_v4().to_string().replace('-', "");
|
||||||
let node_id = format!("node-{}", &uuid_str[0..8]);
|
let node_id = format!("node-{}", &uuid_str[0..8]);
|
||||||
|
|||||||
Reference in New Issue
Block a user