1.3 KiB
1.3 KiB
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_pathandVideo.local_cover_pathare set toNoneafter 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_messagefor visibility. - Existing
ok_uploadedvideos 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.