Fix .quarto_ipynb files not cleaned up after render#14366
Open
Fix .quarto_ipynb files not cleaned up after render#14366
Conversation
- Add `fileNotExists` to verify.ts, mirroring `fileExists` but calling `verifyNoPath` instead of `verifyPath` - Wire `fileNotExists` into smoke-all.test.ts verifyMap handling block alongside the existing `fileExists` block - Add smoke-all test 14359.qmd that verifies the .quarto_ipynb intermediate file is cleaned up after render when keep-ipynb defaults to false
When keep-ipynb is false (the default), cleanupNotebook() now calls safeRemoveSync() to delete the intermediate .quarto_ipynb file immediately after execution, restoring the original behavior from 2021 that was inadvertently dropped when keep-ipynb support was added in PR #12793.
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.
When rendering a
.qmdfile with Jupyter execution, the intermediate.quarto_ipynbfile is never deleted. Each subsequent preview creates numbered variants (_1,_2, etc.) that accumulate on disk.Root Cause
PR #12793 added
keep-ipynb: truesupport by integratingcleanupNotebook()withfileInformationCache. As a side effect, it dropped the immediate file deletion for the defaultkeep-ipynb: falsecase. The function only flips atransientflag in the cache whenkeep-ipynb: trueis set, but does nothing otherwise — the file just stays on disk.Fix
Add an
else if (data.transient)branch incleanupNotebook()that callssafeRemoveSync(target.input)whenkeep-ipynbis false, restoring the original deletion behavior while preserving the cache integration forkeep-ipynb: true.This is safe because
execute()already has a guard (lines 441-447) that recreates the notebook if it's missing, andsafeRemoveSynctolerates missing files.Also adds
fileNotExistsverification to the smoke-all test framework and a test that verifies the.quarto_ipynbfile is cleaned up after render.Fixes #14359