* Fixed stale files not being removed, replaced silently failing glob with own logic.
authorUrban Wallasch <urban.wallasch@freenet.de>
Mon, 3 May 2021 14:12:02 +0000 (16:12 +0200)
committerUrban Wallasch <urban.wallasch@freenet.de>
Mon, 3 May 2021 14:12:02 +0000 (16:12 +0200)
ffpreview.py

index b311a2ac180070a41796812539d9512d5c726cff..93077df5e5484bab120a65689e145d1b682d5371 100755 (executable)
@@ -366,14 +366,16 @@ dur = get_duration(cfg.vid)
 thinfo['duration'] = dur
 thinfo['date'] = int(time.time())
 if cfg.force or not chk_idxfile():
-    stale = [f for f in glob.glob(cfg.tmpdir + '/*.png') if re.match('^' + cfg.tmpdir + '/\d{8}\.png$', f)]
-    stale.append(cfg.idxfile)
-    for f in stale:
-        try:
-            os.unlink(f)
-        except Exception as e:
-            #eprint(str(e))
-            pass
+    try:
+        os.unlink(cfg.idxfile)
+    except Exception as e:
+        pass
+    for f in os.listdir(cfg.tmpdir):
+        if re.match('^\d{8}\.png$', f):
+            try:
+                os.unlink(cfg.tmpdir + '/' + f)
+            except Exception as e:
+                pass
     info1 = Label(scrollframe, text='Processed:', width=10, height=5, anchor='e')
     info2 = Label(scrollframe, text='0', width=10, height=5, anchor='e')
     info3 = Label(scrollframe, text='of ' + (str(dur),'(unknown)')[dur<= 0] + ' s', width=12, height=5, anchor='w')