fix: resolve P2 hardcoded paths to use runtime resolution (A-4.2 P2)
Issues: Direct hardcoded paths without fallback - proxy.rs:108 - audio_track_probe.py - tool_selector.rs:136 - output_dir - ocr.rs:241 - swift_ocr binary - files.rs:1190 - legacy output dirs Impact: These paths don't exist on release machines Solution: 1. proxy.rs: Use path_utils::scripts_dir() 2. tool_selector.rs: Use config::OUTPUT_DIR 3. ocr.rs: Use swift_processor_path() helper 4. face.rs: Make swift_processor_path() public 5. files.rs: Reduce duplicate legacy paths Changes: - src/core/proxy.rs: Resolve audio_track_probe.py - src/core/processor/tool_selector.rs: Use OUTPUT_DIR from config - src/core/processor/ocr.rs: Use swift_processor_path() - src/core/processor/face.rs: Export swift_processor_path() - src/api/files.rs: Deduplicate legacy paths Verification: cargo check --lib passes Remaining: P3 (unwrap_or_else type, ~89 locations) References: - A-4.2 P2 in Momentry_Release_Requirements_20261004.md v1.1 - G-3 gate condition
This commit is contained in:
+2
-1
@@ -1185,9 +1185,10 @@ struct ReScanResponse {
|
||||
|
||||
fn delete_output_files(uuid: &str) -> u64 {
|
||||
let mut deleted_count = 0u64;
|
||||
// Check multiple output directories
|
||||
let output_dirs = [
|
||||
config::OUTPUT_DIR.to_string(),
|
||||
"/Users/accusys/momentry/output".to_string(),
|
||||
// Legacy paths for backward compatibility during migration
|
||||
"/Users/accusys/momentry/output".to_string(),
|
||||
];
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ use super::FaceStatus;
|
||||
|
||||
const FACE_TIMEOUT: Duration = Duration::from_secs(7200);
|
||||
|
||||
fn swift_processor_path(bin: &str) -> std::path::PathBuf {
|
||||
pub fn swift_processor_path(bin: &str) -> std::path::PathBuf {
|
||||
use std::path::PathBuf;
|
||||
let rel = format!(".build/release/{}", bin);
|
||||
let rel = rel.as_str();
|
||||
|
||||
@@ -238,7 +238,8 @@ pub async fn process_ocr(
|
||||
) -> Result<OcrResult> {
|
||||
tracing::info!("[OCR] Starting text recognition: {}", video_path);
|
||||
|
||||
let swift_ocr_path = std::path::Path::new("/Users/accusys/momentry_core/scripts/swift_processors/.build/release/swift_ocr");
|
||||
// Resolve Swift OCR processor path
|
||||
let swift_ocr_path = crate::core::processor::face::swift_processor_path("swift_ocr");
|
||||
|
||||
if swift_ocr_path.exists() {
|
||||
tracing::info!("[OCR] Using Swift processor: {:?}", swift_ocr_path);
|
||||
|
||||
@@ -133,7 +133,9 @@ impl ToolSelector {
|
||||
if let Ok(output_dir) = std::env::var("MOMENTRY_OUTPUT_DIR") {
|
||||
vars.insert("output_dir".to_string(), output_dir);
|
||||
} else {
|
||||
vars.insert("output_dir".to_string(), "/Users/accusys/momentry/output".to_string());
|
||||
// Resolve output_dir from environment or config
|
||||
let output_dir = crate::core::config::OUTPUT_DIR.to_string();
|
||||
vars.insert("output_dir".to_string(), output_dir);
|
||||
}
|
||||
|
||||
vars
|
||||
|
||||
+2
-1
@@ -105,7 +105,8 @@ pub struct AudioTrackResult {
|
||||
|
||||
/// Probe audio track and classify using VAD
|
||||
pub async fn probe_audio_track(file_path: &str) -> Result<Option<AudioTrackResult>> {
|
||||
let script = std::path::Path::new("/Users/accusys/momentry_core/scripts/audio_track_probe.py");
|
||||
let scripts_dir = crate::core::path_utils::scripts_dir();
|
||||
let script = scripts_dir.join("audio_track_probe.py");
|
||||
|
||||
if !script.exists() {
|
||||
tracing::warn!("[AUDIO_TRACK] Script not found: {}", script.display());
|
||||
|
||||
Reference in New Issue
Block a user