fix: delete_video - add file existence check + fix pre_chunks UUID cast

- unregister: check file exists before delete, return 200 with success:false if not found
- delete_video: cast pre_chunks.file_uuid parameter as UUID (::uuid)
- Added Phase 2 test script (10/10 endpoints passed)
This commit is contained in:
Accusys
2026-05-19 15:51:25 +08:00
parent 611441662f
commit ea6ea02925
3 changed files with 103 additions and 1 deletions

View File

@@ -3525,6 +3525,22 @@ async fn unregister(
}
tracing::info!("[unregister] Unregistering file: {}", uuid);
// Check if video exists first
match db.get_video_by_uuid(uuid).await {
Ok(Some(_)) => {},
Ok(None) => {
return Ok(Json(UnregisterResponse {
success: false,
file_uuid: uuid.to_string(),
message: "File not found".to_string(),
}));
}
Err(e) => {
return Err(StatusCode::INTERNAL_SERVER_ERROR);
}
}
match db.delete_video(uuid).await {
Ok(_) => {
let _ = state.mongo_cache.invalidate_videos_list().await;

View File

@@ -1340,7 +1340,7 @@ impl PostgresDb {
.await?;
let pre_chunks = schema::table_name("pre_chunks");
sqlx::query(&format!("DELETE FROM {} WHERE file_uuid = $1", pre_chunks))
sqlx::query(&format!("DELETE FROM {} WHERE file_uuid = $1::uuid", pre_chunks))
.bind(uuid)
.execute(&self.pool)
.await?;