fix(conversion): clean up temp dirs for unsupported buffers#105
fix(conversion): clean up temp dirs for unsupported buffers#105Co-Messi wants to merge 2 commits intorun-llama:mainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6f08dd1d74
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const result = await convertToPdf(tmpPath, password); | ||
|
|
||
| if ("content" in result || "code" in result) { | ||
| await fs.rm(tmpDir, { recursive: true, force: true }); |
There was a problem hiding this comment.
Handle cleanup failures without masking conversion results
convertBufferToPdf now awaits fs.rm directly when returning passthrough content or a conversion error, so a temp-dir deletion failure (e.g., EPERM/EBUSY on Windows or locked files) will throw and replace the original content/ConversionError result. This is a regression from previous behavior and can make non-PDF buffer parsing fail for cleanup-only reasons; cleanup should be best-effort (catch/log) so conversion outcomes are preserved.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
agreed with this comment
There was a problem hiding this comment.
Changed this so temp-dir cleanup stays best-effort. If fs.rm fails now, convertBufferToPdf() still returns the original passthrough/error result instead of turning cleanup into the primary failure. I also added a regression test for the cleanup-failure case.
Problem
convertBufferToPdf()writes input bytes to a temporary directory before delegating toconvertToPdf(). If the delegated conversion returns passthrough content for an unsupported buffer format, that temporary directory is left behind.What changed
convertBufferToPdf()when delegated conversion returns passthrough content or an errorWhy this fixes it
This keeps the buffer conversion temp directory tied to the lifetime of the attempted conversion instead of only the successful PDF path.
Verification
npm test -- src/conversion/convertToPdf.test.tsnpm run format:checknpm run buildFixes #104