]> www.vanbest.org Git - motioneye-debian/commitdiff
cleanup: never remove the root directory
authorCalin Crisan <ccrisan@gmail.com>
Sat, 19 Sep 2015 11:18:59 +0000 (14:18 +0300)
committerCalin Crisan <ccrisan@gmail.com>
Sat, 19 Sep 2015 11:18:59 +0000 (14:18 +0300)
motioneye/cleanup.py
motioneye/mediafiles.py

index a032ef16bbc4444376e1d0f9596fcc6ac70eeb6d..f63520075d790b388358a68e0dbd24c97c418f9a 100644 (file)
@@ -31,9 +31,12 @@ _process = None
 
 
 def start():
+    if not settings.CLEANUP_INTERVAL:
+        return
+
     # schedule the first call a bit later to improve performance at startup
     ioloop = tornado.ioloop.IOLoop.instance()
-    ioloop.add_timeout(datetime.timedelta(seconds=60), _run_process)
+    ioloop.add_timeout(datetime.timedelta(seconds=min(settings.CLEANUP_INTERVAL, 60)), _run_process)
 
 
 def stop():
index 88252b471deb9c6861e41cc86046c2959d603182..42149fafb75995a815794ef42cd36e1469d8e7a3 100644 (file)
@@ -190,8 +190,11 @@ def cleanup_media(media_type):
             continue # only cleanup movies for cameras with movies enabled
 
         preserve_moment = datetime.datetime.now() - datetime.timedelta(days=preserve_media)
-            
+
         target_dir = camera_config.get('target_dir')
+        # create a sentinel file to make sure the target dir is never removed
+        open(os.path.join(target_dir, '.keep'), 'w').close()
+
         _remove_older_files(target_dir, preserve_moment, exts=exts)