metube/app
Helmut e75487efae fix(ytdl): trash button should also remove sidecars + empty parents
DELETE_FILE_ON_TRASHCAN currently removes just the one filename the
download record points at — yt-dlp's same-stem sidecars (writethumbnail's
.jpg/.webp, writesubtitles' .vtt/.srt, writeinfojson's .info.json,
writedescription's .description) stay behind, and the (now usually
empty) per-uploader directory remains. From the user's perspective the
🗑 button claims to delete the item but actually leaves orphan files
and empty directories on disk.

This patch refactors clear()'s removal step into a helper that:

1. Walks the main file's directory once and removes every entry whose
   name starts with '<main-stem>.', covering the main file itself and
   any same-stem sidecar yt-dlp may have written. The trailing dot
   prevents collateral hits on siblings like 'Title [id] (alt).mp4'.

2. Climbs upwards from the file's directory with os.rmdir(), stopping
   the moment a directory is non-empty (rmdir raises OSError) or we
   hit the bucket root. realpath()'d paths on both sides guarantee a
   symlinked layout can't trick the walk above the bucket.

Result: the directory structure is restored to what it would have
been if the download had never happened. No new dependencies, no
new envs, no change to the existing DELETE_FILE_ON_TRASHCAN flag.
2026-06-13 22:04:29 +02:00
..
tests support live streams (closes #302, closes #752, closes #978) 2026-06-13 17:39:14 +03:00
dl_formats.py code review fixes 2026-03-15 20:53:13 +02:00
main.py add option for following nightly yt-dlp releases (closes #999) 2026-06-06 09:42:26 +03:00
state_store.py add subscriptions; change persistence file format to JSON (closes #901, #76, #113, #170, #242, #444, #503, #555, #566) 2026-04-01 14:33:24 +03:00
subscriptions.py allow filtering out members-only videos in subscriptions (closes #971) 2026-04-28 22:02:05 +03:00
ytdl.py fix(ytdl): trash button should also remove sidecars + empty parents 2026-06-13 22:04:29 +02:00