]> www.vanbest.org Git - motioneye-debian/commitdiff
prevented error in log file when adding a camera with inexistent target directory
authorCalin Crisan <ccrisan@gmail.com>
Tue, 13 Sep 2016 18:53:09 +0000 (21:53 +0300)
committerCalin Crisan <ccrisan@gmail.com>
Tue, 13 Sep 2016 18:53:09 +0000 (21:53 +0300)
motioneye/config.py

index bfbafecaff6a103c8d95a1d9d20b169250baa0bc..4be2fb5d2fcb7dc0193535cd3aa07bf3d3bcda3b 100644 (file)
@@ -786,6 +786,7 @@ def motion_camera_ui_to_dict(ui, old_config=None):
     # try to create the target dir
     try:
         os.makedirs(data['target_dir'])
+        logging.debug('created root directory %s for camera %s' % (data['target_dir'], data['@name']))
     
     except Exception as e:
         if isinstance(e, OSError) and e.errno == errno.EEXIST:
@@ -1146,10 +1147,12 @@ def motion_camera_dict_to_ui(data):
         ui['root_directory'] = data['target_dir']
 
     # disk usage
-    usage = utils.get_disk_usage(data['target_dir'])
+    usage = None
+    if os.path.exists(data['target_dir']):
+        usage = utils.get_disk_usage(data['target_dir'])
     if usage:
         ui['disk_used'], ui['disk_total'] = usage
-    
+
     text_left = data['text_left']
     text_right = data['text_right'] 
     if text_left or text_right: