-
-
Notifications
You must be signed in to change notification settings - Fork 702
Description
Description
When assets are deleted through the web interface, orphaned files remain in the screenly_assets folder. The asset deletion process only removes the main file referenced in the database (asset.uri) but doesn't clean up temporary or related files that may have been created during upload, processing, or background operations.
Steps to Reproduce
- Create multiple video assets (MP4 files) in Anthias
- Delete all assets except one through the web interface
- SSH into the device and check the
screenly_assetsfolder:ls ~/screenly_assets - Observe that more files exist than expected (should be 1 file, but multiple files remain)
Expected Behavior
When an asset is deleted through the web interface, all associated files should be removed from the screenly_assets folder, leaving only files for active assets.
Root Cause
The deletion logic in api/views/mixins.py:34-45 (DeleteAssetViewMixin.delete()) only removes the file at asset.uri. It doesn't clean up:
- Temporary files from incomplete or failed uploads
- Files created during chunked upload processes that were renamed from
.tmpto final format - Files from YouTube downloads that completed in background after asset deletion
- Orphaned files from interrupted operations
The hourly cleanup task in celery_tasks.py:60-67 only removes .tmp files, but doesn't catch files that were already renamed to their final format (e.g., .mp4) before the asset creation failed.
Affected Code
api/views/mixins.py-DeleteAssetViewMixin(lines 31-45)api/views/mixins.py-FileAssetViewMixin(lines 138-189) - chunked upload handlingapi/serializers/mixins.py- file renaming during asset creation (lines 52-57)lib/utils.py-YoutubeDownloadThread(lines 415-443) - background downloadscelery_tasks.py- cleanup task (lines 60-67)
Proposed Solution
- Track all temporary files associated with an asset (possibly in Redis or a temporary table)
- Enhance
DeleteAssetViewMixinto find and delete all files related to an asset, not justasset.uri - Implement cleanup for orphaned files from failed YouTube downloads
- Improve the periodic cleanup task to identify and remove orphaned files based on asset ID matching
Environment
- Reported via Anthias forums: https://forums.screenly.io/t/active-assets-issue/6636
- Affects all video (MP4) assets
- Issue occurs across different installation methods