fix: Scene VLM 全流程 per-library 路徑
Core Test / lint-and-test (push) Has been cancelled
Cross-Project Integration / integration (push) Has been cancelled

- job_worker: cut.json 檢查 + output_dir + scenes_path 改用 get_output_dir_for_file
- media_api: scene_thumbnail 改用 per-library + global fallback
- 確保 test library 的 scenes.json 與 scene jpg 寫到 output/test/
- 已搬移舊 scene jpg 從 demo 到 test
This commit is contained in:
Accusys
2026-11-19 15:06:10 +08:00
parent 0be345eb24
commit f5363ca862
2 changed files with 16 additions and 9 deletions
+13 -6
View File
@@ -1102,10 +1102,11 @@ async fn trace_thumbnail(
/// Path mirrors `thumbnail_url` produced by the VLM scene search API.
/// e.g. /api/v1/file/{file_uuid}/scenes/scene_000.jpg
pub async fn scene_thumbnail(
State(_state): State<crate::api::types::AppState>,
State(state): State<crate::api::types::AppState>,
Path((file_uuid, filename)): Path<(String, String)>,
) -> Result<impl IntoResponse, StatusCode> {
let output_dir = crate::core::config::OUTPUT_DIR.as_str();
// Try per-library output dir first (test files live in output/test)
let per_lib = crate::core::config::get_output_dir_for_file(&file_uuid, state.db.pool()).await;
// Security: validate file_uuid to prevent path traversal
if !crate::core::thumbnail::validator::is_valid_file_uuid(&file_uuid) {
@@ -1120,10 +1121,16 @@ pub async fn scene_thumbnail(
.map(|_| filename.clone())
.ok_or(StatusCode::NOT_FOUND)?;
let file_path = std::path::PathBuf::from(output_dir)
.join(&file_uuid)
.join("scenes")
.join(&safe_name);
let global_dir = crate::core::config::OUTPUT_DIR.as_str();
let candidate1 = std::path::PathBuf::from(&per_lib)
.join(&file_uuid).join("scenes").join(&safe_name);
let candidate2 = std::path::PathBuf::from(global_dir)
.join(&file_uuid).join("scenes").join(&safe_name);
let file_path = if candidate1.exists() {
candidate1
} else {
candidate2
};
if !file_path.exists() {
return Err(StatusCode::NOT_FOUND);
+3 -3
View File
@@ -3773,13 +3773,13 @@ async fn process_job(&self, job: crate::core::db::MonitorJob) -> Result<()> {
.all(|p| p == "scene_vlm" || p == "scene");
let cut_json_exists = std::path::Path::new(&format!(
"{}/{}.cut.json",
crate::core::config::OUTPUT_DIR.as_str(),
crate::core::config::get_output_dir_for_file(uuid, self.db.pool()).await.trim_end_matches('/'),
uuid
))
.exists();
if has_cut || (wants_scene_vlm && cut_json_exists) {
let output_dir = crate::core::config::OUTPUT_DIR.clone();
let scenes_path = format!("{}/{}.scenes.json", output_dir, uuid);
let output_dir = crate::core::config::get_output_dir_for_file(uuid, self.db.pool()).await;
let scenes_path = format!("{}/{}.scenes.json", output_dir.trim_end_matches('/'), uuid);
// 重跑條件:scenes.json 不存在 或 未完整完成(vlm completed 數 < total_scenes)
let scene_vlm_complete = if std::path::Path::new(&scenes_path).exists() {