Skip to content

Commit 2d67c02

Browse files
committed
Fix read-only filesystem error: auto-fallback to ~/Desktop for output
When the VCF file is on a read-only volume (e.g., opened directly from .dmg, network mount, or external drive), the core library fails trying to write output files in the same directory. Now run_analysis tests writability of the VCF's parent directory before running. If not writable, falls back to ~/Desktop (or ~ if no Desktop). Uses HOME/USERPROFILE env vars — no new dependencies needed.
1 parent 2be2654 commit 2d67c02

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

src-tauri/src/commands.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,28 @@ pub fn run_analysis(
136136
app_handle: tauri::AppHandle,
137137
config: AnalysisConfig,
138138
) -> Result<serde_json::Value, String> {
139-
let args = config.into_args();
139+
let mut args = config.into_args();
140+
141+
// If no explicit output dir, default to VCF's parent directory.
142+
// If that's not writable (e.g., read-only volume, .dmg), fall back to ~/Desktop.
143+
if args.output_dir.is_none() {
144+
let vcf_dir = std::path::Path::new(&args.vcf_file)
145+
.parent()
146+
.unwrap_or(std::path::Path::new("."));
147+
let test_file = vcf_dir.join(".get_mnv_write_test");
148+
let writable = std::fs::write(&test_file, b"").is_ok();
149+
if writable {
150+
let _ = std::fs::remove_file(&test_file);
151+
} else if let Ok(home) = std::env::var("HOME").or_else(|_| std::env::var("USERPROFILE")) {
152+
let home_path = std::path::PathBuf::from(&home);
153+
let desktop = home_path.join("Desktop");
154+
if desktop.is_dir() {
155+
args.output_dir = Some(desktop.to_string_lossy().into_owned());
156+
} else {
157+
args.output_dir = Some(home);
158+
}
159+
}
160+
}
140161

141162
let progress_callback = move |evt: get_mnv::pipeline::ProgressEvent| {
142163
let _ = app_handle.emit("analysis-progress", &evt);

0 commit comments

Comments
 (0)