Skip to main content

fs/latest_download: ignore partially downloaded Firefox files

ID
ffa323a
date
2026-06-07 20:04:07+00:00
author
Alex Chan <alex@alexwlchan.net>
parent
0c70f38
message
fs/latest_download: ignore partially downloaded Firefox files
changed files
1 file, 5 additions, 6 deletions

Changed files

fs/latest_download (714) → fs/latest_download (754)

diff --git a/fs/latest_download b/fs/latest_download
index d7a3208..99dbbfb 100755
--- a/fs/latest_download
+++ b/fs/latest_download
@@ -6,7 +6,6 @@ I use it when I've downloaded a file in my web browser, and I want
 to use that file immediately without checking what its filename is.
 """
 
-import datetime
 import os
 
 
@@ -22,12 +21,12 @@ def get_downloads():
         if f == ".DS_Store":
             continue
 
-        yield p
-
+        # Exclude partially downloaded files from Firefox
+        if f.endswith(".part"):
+            continue
 
-def downloaded_time(p):
-    return os.stat(p).st_mtime
+        yield p
 
 
 if __name__ == "__main__":
-    print(max(get_downloads(), key=lambda p: downloaded_time(p)))
+    print(max(get_downloads(), key=lambda p: os.stat(p).st_mtime))