fix: download_json 使用 per-library 路徑 — 修復 test library 卡片 detail 查看 json 失敗
- proxy /api/v1/processor-json 實際呼叫 POST /api/v1/file/:uuid/json/:processor (download_json) - download_json 原本用全域 OUTPUT_DIR(demo),test 檔案在 output/test → 404 - 改用 get_output_dir_for_file + global fallback - face_trace → face_traced.json 映射
This commit is contained in:
+12
-2
@@ -587,8 +587,18 @@ async fn download_json(
|
||||
State(state): State<AppState>,
|
||||
Path((file_uuid, processor)): Path<(String, String)>,
|
||||
) -> Result<Json<serde_json::Value>, StatusCode> {
|
||||
let output_dir = crate::core::config::OUTPUT_DIR.to_string();
|
||||
let path = std::path::Path::new(&output_dir).join(format!("{}.{}.json", file_uuid, processor));
|
||||
let per_lib_dir = crate::core::config::get_output_dir_for_file(&file_uuid, state.db.pool()).await;
|
||||
let global_dir = crate::core::config::OUTPUT_DIR.as_str();
|
||||
// face_trace processor writes as face_traced.json
|
||||
let ext = if processor == "face_trace" { "face_traced" } else { processor.as_str() };
|
||||
let filename = format!("{}.{}.json", file_uuid, ext);
|
||||
let candidates = [
|
||||
std::path::Path::new(&per_lib_dir).join(&filename),
|
||||
std::path::Path::new(global_dir).join(&filename),
|
||||
];
|
||||
let path = candidates.iter().find(|p| p.exists())
|
||||
.cloned()
|
||||
.unwrap_or_else(|| candidates[0].clone());
|
||||
let content = tokio::fs::read_to_string(&path)
|
||||
.await
|
||||
.map_err(|_| StatusCode::NOT_FOUND)?;
|
||||
|
||||
Reference in New Issue
Block a user