File: cleanfilecache.py

package info (click to toggle)
django-cacheops 7.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 404 kB
  • sloc: python: 3,189; sh: 7; makefile: 4
file content (18 lines) | stat: -rw-r--r-- 503 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import os

from django.core.management.base import BaseCommand

from cacheops.conf import settings


class Command(BaseCommand):
    help = 'Clean filebased cache'

    def add_arguments(self, parser):
        parser.add_argument('path', nargs='*', default=['default'])

    def handle(self, **options):
        for path in options['path']:
            if path == 'default':
                path = settings.FILE_CACHE_DIR
            os.system(r'find %s -type f \! -iname "\." -mmin +0 -delete' % path)