fix: replace hardcoded fallback paths with relative paths (A-4.2 P3)
Issues: 4 fallback paths in admin_config.rs - default_output_dir: /Users/accusys/momentry/output - default_backup_dir: /Users/accusys/momentry/backup/momentry - default_scripts_dir: /Users/accusys/momentry_core_0.1/tools/script - default_cli_dir: /Users/accusys/momentry_core_0.1/tools/cli Solution: Use current_exe() relative paths as fallback - var/output, var/backup, tools/script, tools/cli - Works on any machine without hardcoding Changes: - All 4 default functions now use relative paths - Falls back to current_exe() sibling directories Verification: cargo check --lib passes Remaining: ~31 P3 locations in other files References: - A-4.2 P3 in Momentry_Release_Requirements_20261004.md v1.1 - G-3 gate condition
This commit is contained in:
@@ -86,22 +86,47 @@ pub struct PathsConfig {
|
||||
|
||||
fn default_output_dir() -> String {
|
||||
std::env::var("MOMENTRY_OUTPUT_DIR")
|
||||
.unwrap_or_else(|_| "/Users/accusys/momentry/output".to_string())
|
||||
.unwrap_or_else(|_| {
|
||||
// Fallback: use relative path from current_exe
|
||||
std::env::current_exe()
|
||||
.ok()
|
||||
.and_then(|p| p.parent().map(|d| d.join("var/output")))
|
||||
.map(|p| p.to_string_lossy().to_string())
|
||||
.unwrap_or_else(|| "var/output".to_string())
|
||||
})
|
||||
}
|
||||
|
||||
fn default_backup_dir() -> String {
|
||||
std::env::var("MOMENTRY_BACKUP_DIR")
|
||||
.unwrap_or_else(|_| "/Users/accusys/momentry/backup/momentry".to_string())
|
||||
.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())
|
||||
})
|
||||
}
|
||||
|
||||
fn default_scripts_dir() -> String {
|
||||
std::env::var("MOMENTRY_SCRIPTS_DIR")
|
||||
.unwrap_or_else(|_| "/Users/accusys/momentry_core_0.1/tools/script".to_string())
|
||||
.unwrap_or_else(|_| {
|
||||
std::env::current_exe()
|
||||
.ok()
|
||||
.and_then(|p| p.parent().map(|d| d.join("tools/script")))
|
||||
.map(|p| p.to_string_lossy().to_string())
|
||||
.unwrap_or_else(|| "tools/script".to_string())
|
||||
})
|
||||
}
|
||||
|
||||
fn default_cli_dir() -> String {
|
||||
std::env::var("MOMENTRY_CLI_DIR")
|
||||
.unwrap_or_else(|_| "/Users/accusys/momentry_core_0.1/tools/cli".to_string())
|
||||
.unwrap_or_else(|_| {
|
||||
std::env::current_exe()
|
||||
.ok()
|
||||
.and_then(|p| p.parent().map(|d| d.join("tools/cli")))
|
||||
.map(|p| p.to_string_lossy().to_string())
|
||||
.unwrap_or_else(|| "tools/cli".to_string())
|
||||
})
|
||||
}
|
||||
|
||||
fn default_python_path() -> String {
|
||||
|
||||
Reference in New Issue
Block a user