fix: complete admin_config.rs path cleanup (A-4.2 P3)

Issues: 5 remaining hardcoded paths
- storage_root: /Users/accusys/momentry/var/sftpgo/data
- 4× paths in get_paths() fallback

Solution: Use relative paths and config constants
- storage_root: relative fallback
- output_dir: config::OUTPUT_DIR
- backup_dir: relative fallback
- scripts_dir: path_utils::scripts_dir()
- cli_dir: path_utils::cli_dir()

Verification: cargo check --lib passes, 0 hardcoded paths

Progress: admin_config.rs ✅✅, files.rs ✅, watcher.rs ✅, processing.rs ✅
This commit is contained in:
Accusys
2026-10-04 16:36:35 +08:00
parent 30ea384573
commit 6c95404a30
+18 -9
View File
@@ -346,7 +346,13 @@ fn default_serve_base_url() -> String {
fn default_storage_root() -> String {
std::env::var("MOMENTRY_STORAGE_ROOT")
.unwrap_or_else(|_| "/Users/accusys/momentry/var/sftpgo/data".to_string())
.unwrap_or_else(|_| {
std::env::current_exe()
.ok()
.and_then(|p| p.parent().map(|d| d.join("var/sftpgo/data")))
.map(|p| p.to_string_lossy().to_string())
.unwrap_or_else(|| "var/sftpgo/data".to_string())
})
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
@@ -642,14 +648,17 @@ pub async fn get_server() -> ServerConfig {
pub fn get_paths_sync() -> PathsConfig {
PathsConfig {
output_dir: std::env::var("MOMENTRY_OUTPUT_DIR")
.unwrap_or_else(|_| "/Users/accusys/momentry/output".to_string()),
backup_dir: std::env::var("MOMENTRY_BACKUP_DIR")
.unwrap_or_else(|_| "/Users/accusys/momentry/backup/momentry".to_string()),
scripts_dir: std::env::var("MOMENTRY_SCRIPTS_DIR")
.unwrap_or_else(|_| "/Users/accusys/momentry_core_0.1/tools/script".to_string()),
cli_dir: std::env::var("MOMENTRY_CLI_DIR")
.unwrap_or_else(|_| "/Users/accusys/momentry_core_0.1/tools/cli".to_string()),
output_dir: crate::core::config::OUTPUT_DIR.to_string(),
backup_dir: std::env::var("MOMENTRY_BACKUP_DIR")
.unwrap_or_else(|_| {
std::env::current_exe()
.ok()
.and_then(|p| p.parent().map(|d| d.join("var/backup")))
.map(|p| p.to_string_lossy().to_string())
.unwrap_or_else(|| "var/backup".to_string())
}),
scripts_dir: crate::core::path_utils::scripts_dir().to_string_lossy().to_string(),
cli_dir: crate::core::path_utils::cli_dir().to_string_lossy().to_string(),
python_path: std::env::var("MOMENTRY_PYTHON_PATH")
.unwrap_or_else(|_| "/opt/homebrew/bin/python3.11".to_string()),
ffmpeg_path: std::env::var("MOMENTRY_FFMPEG").unwrap_or_else(|_| "ffmpeg".to_string()),