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. |
||
|---|---|---|
| .. | ||
| tests | ||
| dl_formats.py | ||
| main.py | ||
| state_store.py | ||
| subscriptions.py | ||
| ytdl.py | ||