Repository navigation
fix(converter): keep multi-hop output when no output dir is set - #28
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #27.
Problem
In
convert_file, the final hop of a multi-hop chain (e.g. png → pdf → html) passedconfig.output_dirthrough unchanged. When it wasNone(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 asSome(..)to the final hop. Single-hop conversions are untouched.Tests
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 withoutput 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