From a4e176c682236d8082c62787e4bede5583b7163d Mon Sep 17 00:00:00 2001 From: Accusys Date: Thu, 19 Nov 2026 13:46:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20download=5Fjson=20=E4=BD=BF=E7=94=A8=20p?= =?UTF-8?q?er-library=20=E8=B7=AF=E5=BE=91=20=E2=80=94=20=E4=BF=AE?= =?UTF-8?q?=E5=BE=A9=20test=20library=20=E5=8D=A1=E7=89=87=20detail=20?= =?UTF-8?q?=E6=9F=A5=E7=9C=8B=20json=20=E5=A4=B1=E6=95=97=20-=20proxy=20/a?= =?UTF-8?q?pi/v1/processor-json=20=E5=AF=A6=E9=9A=9B=E5=91=BC=E5=8F=AB=20P?= =?UTF-8?q?OST=20/api/v1/file/:uuid/json/:processor=20(download=5Fjson)=20?= =?UTF-8?q?-=20download=5Fjson=20=E5=8E=9F=E6=9C=AC=E7=94=A8=E5=85=A8?= =?UTF-8?q?=E5=9F=9F=20OUTPUT=5FDIR(demo)=EF=BC=8Ctest=20=E6=AA=94?= =?UTF-8?q?=E6=A1=88=E5=9C=A8=20output/test=20=E2=86=92=20404=20-=20?= =?UTF-8?q?=E6=94=B9=E7=94=A8=20get=5Foutput=5Fdir=5Ffor=5Ffile=20+=20glob?= =?UTF-8?q?al=20fallback=20-=20face=5Ftrace=20=E2=86=92=20face=5Ftraced.js?= =?UTF-8?q?on=20=E6=98=A0=E5=B0=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/processing.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/api/processing.rs b/src/api/processing.rs index a019ab55..9f4e1941 100644 --- a/src/api/processing.rs +++ b/src/api/processing.rs @@ -587,8 +587,18 @@ async fn download_json( State(state): State, Path((file_uuid, processor)): Path<(String, String)>, ) -> Result, 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)?;