emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 42fedf5 116/184: counsel.el (counsel-file-stale-p): Extrac


From: Oleh Krehel
Subject: [elpa] master 42fedf5 116/184: counsel.el (counsel-file-stale-p): Extract
Date: Wed, 16 Oct 2019 13:15:02 -0400 (EDT)

branch: master
commit 42fedf55a6e6507623063ea6f9bfd7b093bceeeb
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    counsel.el (counsel-file-stale-p): Extract
---
 counsel.el | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/counsel.el b/counsel.el
index c8567cc..1476f38 100644
--- a/counsel.el
+++ b/counsel.el
@@ -2465,16 +2465,20 @@ string - the full shell command to run."
   "Location where to put the locatedb in case your home folder is encrypted."
   :type 'file)
 
+(defun counsel-file-stale-p (fname seconds)
+  "Return non-nil if FNAME was modified more than SECONDS ago."
+  (> (time-to-seconds
+      (time-subtract
+       (current-time)
+       (nth 5 (file-attributes fname))))
+     seconds))
+
 (defun counsel--locate-updatedb ()
   (when (file-exists-p "~/.Private")
     (let ((db-fname (expand-file-name counsel-locate-db-path)))
       (setenv "LOCATE_PATH" db-fname)
       (when (or (not (file-exists-p db-fname))
-                (> (time-to-seconds
-                    (time-subtract
-                     (current-time)
-                     (nth 5 (file-attributes db-fname))))
-                   60))
+                (counsel-file-stale-p db-fname 60))
         (message "Updating %s..." db-fname)
         (counsel--command
          "updatedb" "-l" "0" "-o" db-fname "-U" (expand-file-name "~"))))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]