feat: Add file_locations to scan and fix file info API
Problem: - Files could not be clicked (error: no location) - get_file_info used hardcoded demo database - file_locations table was empty Solution: 1. Scan now inserts file_locations records - file_uuid = node_id (temporary) - location = file path (from aliases) - label = origin 2. Modified API routes to include user_id - /api/v2/files/:user_id/:file_uuid/info - /api/v2/files/:user_id/:file_uuid/stream 3. Modified showDetail() to use tree_user from localStorage Result: - file_locations: 11857 records ✅ - Files can be clicked ✅ - API uses correct user database ✅ Files: - src/scan.rs (insert file_locations) - src/server.rs (user_id parameter) - src/page.html (showDetail with user_id)
This commit is contained in:
12
src/scan.rs
12
src/scan.rs
@@ -224,6 +224,18 @@ pub fn scan_directory(user_id: &str, dir: &str, batch_size: usize, options: Scan
|
||||
|
||||
for node in file_nodes {
|
||||
insert_node(&conn, &node)?;
|
||||
|
||||
if let Some(ref file_uuid) = node.file_uuid {
|
||||
let path = node.aliases.get("path").cloned().unwrap_or_default();
|
||||
if !path.is_empty() {
|
||||
conn.execute(
|
||||
"INSERT OR IGNORE INTO file_locations (file_uuid, location, label, added_at)
|
||||
VALUES (?1, ?2, 'origin', ?3)",
|
||||
rusqlite::params![file_uuid, path, chrono::Utc::now().timestamp().to_string()],
|
||||
)?;
|
||||
}
|
||||
}
|
||||
|
||||
inserted += 1;
|
||||
|
||||
if inserted % batch_size == 0 {
|
||||
|
||||
Reference in New Issue
Block a user