fix: reset Video record after orphan cleanup#43
Open
dreamcreated wants to merge 1 commit intowindoze95:mainfrom
Open
fix: reset Video record after orphan cleanup#43dreamcreated wants to merge 1 commit intowindoze95:mainfrom
dreamcreated wants to merge 1 commit intowindoze95:mainfrom
Conversation
When check_and_delete_orphan removes all physical files, it previously left the Video.status as 'COMPLETE' and file_path populated. This caused a stale state where: - New UserVideoRef associations would try to stream a missing file (404) - Auto-download logic would skip the video because status='COMPLETE' Fix: after deleting files from disk, reset the Video record: video.status = 'CATALOGED' video.file_path = None video.file_size_bytes = 0 This allows the video to be re-downloaded if a new user subscribes to the channel. Fixes windoze95#17
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
Fixes #17
check_and_delete_orphaninapp/services/storage.pycorrectly removes the physical media, preview, and thumbnail files from disk when a video has no remaining activeUserVideoRefassociations. However, theVideorecord itself is never updated —statusstays"COMPLETE"andfile_pathstill points to the deleted file.Impact:
UserVideoRef, but attempting to stream the video returns a 404 ("Video file missing from disk")status == "COMPLETE", so it never re-downloadsFix
After deleting all files from disk, reset the
Videorecord to reflect its actual state:This makes the video eligible for re-download if a new user subscribes to the channel.
Changes
app/services/storage.py: Resetvideo.status,video.file_path, andvideo.file_size_bytesafter orphan deletion; moveddb.commit()inside the function (was missing entirely).