dzen.nstarikov.ru/docs/superpowers/specs/2026-06-27-video-cleanup-design.md

26 lines
1.3 KiB
Markdown
Raw Normal View History

2026-06-27 14:07:10 +03:00
# Video Cleanup Design
## Goal
Remove all local artifacts produced by `yt-dlp` after a video has been successfully uploaded to OK and an `ok_video_id` has been persisted.
## Behavior
- Cleanup runs only after the OK upload succeeds.
- The complete per-video directory under `storage/vk/<video_id>` is removed, including the MP4, thumbnail, description, and info JSON.
- `Video.local_video_path` and `Video.local_cover_path` are set to `None` after cleanup.
- Failed or incomplete uploads keep their files for retry and diagnosis.
- A cleanup failure does not turn a successful OK upload into a failed upload. It is logged and retained in `Video.error_message` for visibility.
- Existing `ok_uploaded` videos are cleaned once during deployment using the same path-safety rules.
## Safety
Cleanup may remove only a directory resolved beneath `settings.storage_path / "vk"`. Paths outside that root are rejected. Missing files or directories are treated as already cleaned.
## Verification
- Compile the worker module.
- Verify cleanup refuses paths outside the video storage root.
- Verify an existing per-video directory is removed and model paths are cleared.
- Deploy and confirm successful videos retain `ok_video_id`, have null local paths, and leave no corresponding local directory.