fix: sweep fragment partials immediately on cancel - #18
Open
Mr-Neutr0n wants to merge 1 commit into
Open
Mr-Neutr0n wants to merge 1 commit into
Mr-Neutr0n wants to merge 1 commit into
Conversation
Cancelled downloads leaked yt-dlp's range fragments (.part-Frag<n>): the artifact list only knew dest, .part and .ytdl, and cleanup ran inside the close handler, which a surviving grandchild (ffmpeg mid- merge, an orphaned sleep) can hold off for as long as it runs. Sweep the destination's sibling family (exact name, dot-suffixed, dash-suffixed) the moment abort fires instead of waiting for close, and re-sweep in close for lines that streamed past the abort. The filter never touches similarly-named user files. Signed-off-by: Mr-Neutr0n <64578610+Mr-Neutr0n@users.noreply.github.com>
Author
|
Hi @pablostanley - a gentle nudge on sweeping fragment partials on cancel; still mergeable and applies cleanly. Happy to adjust anything, and fine to close if not wanted. Thank you. |
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.
Problem
Cancelling a download leaked yt-dlp's partial files in the output directory. Two stacked causes:
dest,dest.part, anddest.ytdl— but fragmented downloads writedest.part-Frag0,dest.part-Frag1, … siblings that a plain rm of the.partnever touches.closeevent.spawn(bin, args, {signal})signals only the direct child; anything it spawned (an ffmpeg merge step, a shell's sleep) inherits the stdio pipes and keeps them open after the parent dies, delayingcloseby the grandchild's entire runtime. Until it fires, no cleanup happens at all.Reproduced with a scripted fake yt-dlp: cancel mid-download →
.part,.part-Frag0,.part-Frag1all still on disk a minute later.Change
closehandler re-sweeps for any line that streamed past the abort..ytdl,.part*) and dash-suffixed (-Frag<n>), while explicitly not touching similarly-named user files like<dest>-notes.txt.Verification
New
src/lib/ytdlp.test.tsdrives the realdownload()against scripted fake binaries writing actual fragment files:.part+-FragNsiblings (fails on old code, passes now)tsupbuild cleanThis change was prepared with AI assistance under human direction and review.