Skip to content

fix(converter): keep multi-hop output when no output dir is set - #28

Merged
mtmatt merged 1 commit into
mainfrom
fix/chain-output-dir
Sep 28, 2026
Merged

mtmatt merged 1 commit into
mainfrom
fix/chain-output-dir

Conversation

@mtmatt

@mtmatt mtmatt commented Sep 28, 2026

Copy link
Copy Markdown
Owner

Fixes #27.

Problem

In convert_file, the final hop of a multi-hop chain (e.g. png → pdf → html) passed config.output_dir through unchanged. When it was None (CLI without --output-dir, or GUI with no output dir configured), each converter fell back to the parent of that hop's input — the intermediate file inside the chain temp dir. The final artifact landed there and was deleted with the temp dir, while the path was still reported as a success.

Fix

Add chain_output_dir(original, configured), which returns the configured dir, else the original input's directory (. for a bare filename). It's computed once before the loop and passed as Some(..) to the final hop. Single-hop conversions are untouched.

Tests

  • Unit tests for chain_output_dir: configured dir wins, falls back to the input's dir, bare filename → ..
  • tests/chain_cli.rs: the existing png → html e2e chain test now also runs without --output-dir, and asserts that the output lands in the expected directory. Verified that it fails on the old code with output file missing (the exact symptom in CLI: multi-hop conversions lose output when --output-dir is omitted #27) and passes with the fix. It still skips when pandoc/typst/pymupdf4llm are missing.
  • cargo test -- --test-threads=1: 99 passed, 1 ignored. chain_cli: 2/2. No new clippy warnings.

🤖 Generated with Claude Code

The final hop of a chain passed `config.output_dir` through as-is, so
with no output dir the converters fell back to the parent of the hop's
own input -- the intermediate inside the chain temp dir, which is
deleted when `convert_file` returns. Resolve the final hop's directory
against the original input instead.
@mtmatt
mtmatt merged commit 7dcbedd into main Sep 28, 2026
9 checks passed
@mtmatt
mtmatt deleted the fix/chain-output-dir branch September 28, 2026 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI: multi-hop conversions lose output when --output-dir is omitted

1 participant