]> www.vanbest.org Git - motioneye-debian/commitdiff
hidden dirs/files are now properly ignored when listing media files
authorCalin Crisan <ccrisan@gmail.com>
Fri, 4 Mar 2016 20:25:50 +0000 (22:25 +0200)
committerCalin Crisan <ccrisan@gmail.com>
Fri, 4 Mar 2016 20:25:50 +0000 (22:25 +0200)
motioneye/mediafiles.py

index d637d8e3d30ea599f19969cf645ed93982695540..c47a6d8c8c2518a605a9ac586ed9a6be4bfbd265 100644 (file)
@@ -52,6 +52,9 @@ _timelapse_data = None
 def findfiles(path):
     files = []
     for name in os.listdir(path):
+        # ignore hidden files/dirs and other unwanted files
+        if name.startswith('.') or name == 'lastsnap.jpg':
+            continue
         pathname = os.path.join(path, name)
         st = os.lstat(pathname)
         mode = st.st_mode
@@ -73,7 +76,8 @@ def _list_media_files(dir, exts, prefix=None):
         
         root = os.path.join(dir, prefix)
         for name in os.listdir(root):
-            if name == 'lastsnap.jpg' or name.startswith('.'): # ignore the lastsnap.jpg and hidden files
+            # ignore hidden files/dirs and other unwanted files
+            if name.startswith('.') or name == 'lastsnap.jpg':
                 continue
                 
             full_path = os.path.join(root, name)
@@ -95,12 +99,6 @@ def _list_media_files(dir, exts, prefix=None):
 
     else:
         for full_path, name, st in findfiles(dir):
-            if name == 'lastsnap.jpg' or name.startswith('.'): # ignore the lastsnap.jpg and hidden files
-                continue
-
-            if not stat.S_ISREG(st.st_mode): # not a regular file
-                continue
-
             full_path_lower = full_path.lower()
             if not [e for e in exts if full_path_lower.endswith(e)]:
                 continue