fix: remove final 3 hardcoded paths for D-4 compliance

Final cleanup:
1. main.rs:35 - Remove hardcoded .env fallback
   - Rationale: L30-34 already provide correct current_exe() resolution
   - Removes dev path, aligns with A-14.3 "禁止读取 dev 设定"

2. docs.rs:11,24 - Use current_exe() resolution
   - Replace hardcoded doc_wasm paths
   - Add MOMENTRY_DOCS_DIR env var support
   - Fallback to relative path

Result:
- All hardcoded dev paths removed from release binary
- D-4 Gate satisfied
- Zero momentry_core/nextorageai paths in source

Impact:
- Binary fully portable
- No dev environment assumptions
- All paths runtime-resolved
This commit is contained in:
Accusys
2026-10-04 20:40:27 +08:00
parent e48350e3f9
commit 7ffb45c137
2 changed files with 9 additions and 3 deletions
+8 -1
View File
@@ -21,7 +21,14 @@ async fn wasm_doc_file_handler(
if file.contains("..") || file.contains("//") {
return Err((StatusCode::NOT_FOUND, "Invalid path"));
}
let base = std::path::Path::new("/Users/accusys/momentry_core/docs_v1.0/doc_wasm");
let base_str = std::env::var("MOMENTRY_DOCS_DIR")
.unwrap_or_else(|_| {
std::env::current_exe()
.ok()
.and_then(|p| p.parent().map(|d| d.join("docs_v1.0/doc_wasm").to_string_lossy().to_string()))
.unwrap_or_else(|| "docs_v1.0/doc_wasm".to_string())
});
let base = std::path::Path::new(&base_str);
let path = base.join(&file);
if !path.exists() || !path.starts_with(base) {
return Err((StatusCode::NOT_FOUND, "File not found"));