only run cleanup if folders exist
This commit is contained in:
parent
31b98d0707
commit
bc4e715ce4
1 changed files with 10 additions and 7 deletions
|
|
@ -150,14 +150,17 @@ def extract_clip(public_id, in_, out, resolution, format, track=None):
|
||||||
def clear_cache(days=60):
|
def clear_cache(days=60):
|
||||||
import subprocess
|
import subprocess
|
||||||
path = os.path.join(settings.MEDIA_ROOT, 'media')
|
path = os.path.join(settings.MEDIA_ROOT, 'media')
|
||||||
cmd = ['find', path, '-iregex', '.*/frames/.*', '-atime', '+%s' % days, '-type', 'f', '-exec', 'rm', '{}', ';']
|
if os.path.exists(path):
|
||||||
subprocess.check_output(cmd)
|
cmd = ['find', path, '-iregex', '.*/frames/.*', '-atime', '+%s' % days, '-type', 'f', '-exec', 'rm', '{}', ';']
|
||||||
path = os.path.join(settings.MEDIA_ROOT, 'items')
|
subprocess.check_output(cmd)
|
||||||
cmd = ['find', path, '-iregex', '.*/cache/.*', '-atime', '+%s' % days, '-type', 'f', '-exec', 'rm', '{}', ';']
|
if os.path.exists(path):
|
||||||
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)
|
||||||
path = settings.MEDIA_ROOT
|
path = settings.MEDIA_ROOT
|
||||||
cmd = ['find', path, '-type', 'd', '-size', '0', '-prune', '-exec', 'rmdir', '{}', ';']
|
if os.path.exists(path):
|
||||||
subprocess.check_output(cmd)
|
cmd = ['find', path, '-type', 'd', '-size', '0', '-prune', '-exec', 'rmdir', '{}', ';']
|
||||||
|
subprocess.check_output(cmd)
|
||||||
|
|
||||||
|
|
||||||
@app.task(ignore_results=True, queue='default')
|
@app.task(ignore_results=True, queue='default')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue