branch: elpa/projectile
commit fe536f569d2e1974c6976415f89af100a9bf80af
Author: Bozhidar Batsov <[email protected]>
Commit: Bozhidar Batsov <[email protected]>

    Handle deleted files in sort-by-modification/access-time
    
    file-attributes returns nil for deleted files, causing
    file-attribute-modification-time to error. Use 0 as the fallback
    timestamp so deleted files sort to the end instead of crashing.
---
 projectile.el | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/projectile.el b/projectile.el
index e7f84bf20e..ff68cb7450 100644
--- a/projectile.el
+++ b/projectile.el
@@ -2729,7 +2729,8 @@ Parameters MODE VARIABLE VALUE are passed directly to
   (let ((default-directory (projectile-project-root))
         (mtimes (make-hash-table :test 'equal :size (length files))))
     (dolist (file files)
-      (puthash file (file-attribute-modification-time (file-attributes file)) 
mtimes))
+      (let ((attrs (file-attributes file)))
+        (puthash file (if attrs (file-attribute-modification-time attrs) 0) 
mtimes)))
     (seq-sort (lambda (file1 file2)
                 (not (time-less-p (gethash file1 mtimes)
                                   (gethash file2 mtimes))))
@@ -2740,7 +2741,8 @@ Parameters MODE VARIABLE VALUE are passed directly to
   (let ((default-directory (projectile-project-root))
         (atimes (make-hash-table :test 'equal :size (length files))))
     (dolist (file files)
-      (puthash file (file-attribute-access-time (file-attributes file)) 
atimes))
+      (let ((attrs (file-attributes file)))
+        (puthash file (if attrs (file-attribute-access-time attrs) 0) atimes)))
     (seq-sort (lambda (file1 file2)
                 (not (time-less-p (gethash file1 atimes)
                                   (gethash file2 atimes))))

Reply via email to