From 139b0da2ebc7af8f3d9f64d69a61ff7eac68344e Mon Sep 17 00:00:00 2001
From: Andre Anjos <andre.dos.anjos@gmail.com>
Date: Fri, 22 Apr 2016 12:32:01 +0200
Subject: [PATCH] [backend] Allow user to set path to clean-up

---
 .../web/backend/management/commands/cleanup_cache.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/beat/web/backend/management/commands/cleanup_cache.py b/beat/web/backend/management/commands/cleanup_cache.py
index 96d0b5513..2adec94db 100644
--- a/beat/web/backend/management/commands/cleanup_cache.py
+++ b/beat/web/backend/management/commands/cleanup_cache.py
@@ -46,12 +46,18 @@ class Command(BaseCommand):
         parser.add_argument('--olderthan', type=int, metavar='MINUTES',
             default=0, help='All files which are older than this value ' \
                 'in *minutes* and are not locked or being used by active ' \
-                'experiments (running or scheduled) will be deleted')
+                'experiments (running or scheduled) will be deleted ' \
+                '[default: %(default)s]')
 
         parser.add_argument('--delete', action='store_true', default=False,
             help='By default we only list cache files that will ' \
                 'be erased. If you pass this flag, then we really erase them')
 
+        parser.add_argument('--path', default=settings.CACHE_ROOT,
+            help='By default, we erase the CACHE path on your settings. Set ' \
+                'this flag if you want to operate on a different path ' \
+                '[default: %(default)s]')
+
 
     def handle(self, *ignored, **arguments):
 
@@ -62,11 +68,11 @@ class Command(BaseCommand):
             if arguments['verbosity'] == 1: logger.setLevel(logging.INFO)
             elif arguments['verbosity'] >= 2: logger.setLevel(logging.DEBUG)
 
-        deleted = cleanup_cache(settings.CACHE_ROOT,
+        deleted = cleanup_cache(arguments['path'],
             age_in_minutes=arguments['olderthan'],
             delete=arguments['delete'])
 
         if not arguments['delete']:
             print("%d cache files can be deleted" % len(deleted))
             for k in deleted:
-                print(os.path.join(settings.CACHE_ROOT, k))
+                print(os.path.join(arguments['path'], k))
-- 
GitLab