From ecc45361eb658ce75ed6c23761d7391a0186bad2 Mon Sep 17 00:00:00 2001 From: Aevann Date: Thu, 24 Oct 2024 19:46:55 +0300 Subject: [PATCH] wipe images, video, audio in /chat/1 that are 1 month old and arent reused anywhere else --- files/helpers/cron.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/files/helpers/cron.py b/files/helpers/cron.py index 33a8000d6..01547af27 100644 --- a/files/helpers/cron.py +++ b/files/helpers/cron.py @@ -462,13 +462,17 @@ def _cleanup_videos(): clean = [x[0] for x in db.query(MediaUsage.filename).filter_by(deleted_utc=None, removed_utc=None)] - to_delete = db.query(Media).join(Media.usages).filter( + to_delete = db.query(Media).outerjoin(Media.usages).filter( Media.filename.notin_(clean), Media.purged_utc == None, Media.user_id != 380983, or_( MediaUsage.deleted_utc < one_month_ago, MediaUsage.removed_utc < one_month_ago, + and_( + Media.referrer == f'{SITE_FULL}/chat/1', + Media.created_utc < one_month_ago, + ), ), ).order_by(Media.size.desc())