diff --git a/src/api/server.rs b/src/api/server.rs index b725a67..93074bf 100644 --- a/src/api/server.rs +++ b/src/api/server.rs @@ -1370,14 +1370,32 @@ async fn register_single_file( .await { tracing::info!("[REGISTER] Content hash collision → already registered: {}", existing_uuid); - let existing_name: Option = sqlx::query_scalar( - &format!("SELECT file_name FROM {} WHERE file_uuid = $1", videos_table) + let existing_info: Option<(String, String, f64, i32, i32, f64, i64, Option)> = sqlx::query_as( + &format!("SELECT file_name, file_path, duration, width, height, fps, total_frames, registration_time::text FROM {} WHERE file_uuid = $1", videos_table) ).bind(&existing_uuid).fetch_optional(db.pool()).await.unwrap_or(None); + if let Some((ename, epath, dur, w, h, f, tf, rt)) = existing_info { + return RegisterFileResponse { + success: true, + file_uuid: existing_uuid, + file_name: ename, + file_path: epath.clone(), + file_type: None, + duration: dur, + width: w as u32, + height: h as u32, + fps: f, + total_frames: tf as u64, + registration_time: rt, + already_exists: true, + message: format!("Content already registered: {}", epath), + }; + } + // Fallback: content_hash matched but full info query failed return RegisterFileResponse { success: true, file_uuid: existing_uuid, - file_name: existing_name.unwrap_or(file_name), - file_path: canonical_path, + file_name: file_name.clone(), + file_path: canonical_path.clone(), file_type: None, duration: 0.0, width: 0,