1
Fork 0
mirror of https://github.com/thegeneralist01/archivr synced 2026-07-22 03:05:32 +02:00

fix: diagnose single-file no-output-file error + prevent stdout dumping

- Add --dump-content=false to every single-file invocation to prevent
  the Docker-detection heuristic from routing HTML to stdout instead of
  the output file (the heuristic can trigger in some macOS environments)
- Improve the no-output-file error message to include: temp dir contents,
  stderr, and first 200 chars of stdout — this gives enough context to
  diagnose any remaining cause without re-running
This commit is contained in:
TheGeneralist 2026-07-07 21:17:46 +02:00
parent 596a6d1c89
commit 33eb60bf8b
Signed by: thegeneralist01
SSH key fingerprint: SHA256:pp9qddbCNmVNoSjevdvQvM5z0DHN7LTa8qBMbcMq/R4

View file

@ -316,13 +316,33 @@ fn save_with(
if !sf_output.status.success() {
let stderr = String::from_utf8_lossy(&sf_output.stderr);
bail!("single-file failed: {stderr}");
bail!("single-file failed (exit {:?}): {stderr}", sf_output.status.code());
}
if !out_file.exists() {
// Collect diagnostics: stdout, stderr, and what's actually in the temp dir.
let stdout = String::from_utf8_lossy(&sf_output.stdout);
let stderr = String::from_utf8_lossy(&sf_output.stderr);
let dir_contents: String = std::fs::read_dir(&temp_dir)
.map(|rd| {
rd.filter_map(|e| e.ok())
.map(|e| e.file_name().to_string_lossy().into_owned())
.collect::<Vec<_>>()
.join(", ")
})
.unwrap_or_else(|_| "<unreadable>".to_string());
eprintln!(
"warn: single-file produced no file at {}\n temp dir contents: [{dir_contents}]\n stderr: {}\n stdout (first 200 chars): {}",
out_file.display(),
stderr.trim(),
&stdout[..stdout.len().min(200)],
);
bail!(
"single-file exited successfully but produced no output file at {}",
out_file.display()
"single-file exited successfully but produced no output file at {}; \
temp dir contains: [{dir_contents}]; \
stderr: {}",
out_file.display(),
stderr.trim(),
);
}
@ -433,7 +453,10 @@ fn base_single_file_cmd(
.arg("--remove-alternative-medias=false")
.arg("--block-scripts=false")
.arg("--remove-unused-fonts=false")
.arg("--remove-alternative-fonts=false");
.arg("--remove-alternative-fonts=false")
// Explicitly prevent single-file from dumping HTML to stdout instead of
// writing the file (its Docker-detection heuristic can trigger on some setups).
.arg("--dump-content=false");
for script in scripts {
cmd.arg(format!("--browser-script={}", script.display()));
}