From bc4e715ce46e978da9bfe6168ddcb37312c59763 Mon Sep 17 00:00:00 2001 From: j Date: Tue, 23 Dec 2025 22:14:22 +0100 Subject: [PATCH] only run cleanup if folders exist --- pandora/item/tasks.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/pandora/item/tasks.py b/pandora/item/tasks.py index 92b3b08fd..1d279f1bc 100644 --- a/pandora/item/tasks.py +++ b/pandora/item/tasks.py @@ -150,14 +150,17 @@ def extract_clip(public_id, in_, out, resolution, format, track=None): def clear_cache(days=60): import subprocess path = os.path.join(settings.MEDIA_ROOT, 'media') - cmd = ['find', path, '-iregex', '.*/frames/.*', '-atime', '+%s' % days, '-type', 'f', '-exec', 'rm', '{}', ';'] - subprocess.check_output(cmd) - path = os.path.join(settings.MEDIA_ROOT, 'items') - cmd = ['find', path, '-iregex', '.*/cache/.*', '-atime', '+%s' % days, '-type', 'f', '-exec', 'rm', '{}', ';'] - subprocess.check_output(cmd) + if os.path.exists(path): + cmd = ['find', path, '-iregex', '.*/frames/.*', '-atime', '+%s' % days, '-type', 'f', '-exec', 'rm', '{}', ';'] + subprocess.check_output(cmd) + if os.path.exists(path): + path = os.path.join(settings.MEDIA_ROOT, 'items') + cmd = ['find', path, '-iregex', '.*/cache/.*', '-atime', '+%s' % days, '-type', 'f', '-exec', 'rm', '{}', ';'] + subprocess.check_output(cmd) path = settings.MEDIA_ROOT - cmd = ['find', path, '-type', 'd', '-size', '0', '-prune', '-exec', 'rmdir', '{}', ';'] - subprocess.check_output(cmd) + if os.path.exists(path): + cmd = ['find', path, '-type', 'd', '-size', '0', '-prune', '-exec', 'rmdir', '{}', ';'] + subprocess.check_output(cmd) @app.task(ignore_results=True, queue='default')