aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2017-10-20 19:16:29 -0700
committerPaul Eggert2017-10-20 19:17:04 -0700
commit83db9a1bba20575303fd01f8e67d5c6e09e3d72a (patch)
tree22582c06a4ada43f1305068696ab3cf10c822c6e
parente655946ce0946b7081b037fa50be4d3fb1609b0b (diff)
downloademacs-83db9a1bba20575303fd01f8e67d5c6e09e3d72a.tar.gz
emacs-83db9a1bba20575303fd01f8e67d5c6e09e3d72a.zip
Fix two more minor Gnus typos
* lisp/gnus/mail-source.el (mail-source-delete-old-incoming): The old code had two minor bugs: first, it multiplied by 1/65536 instead of by 1/86400. Second, it called current-time twice and glued part of the two results together, resulting in a race. Fix both bugs by simplifying the code and using time-to-number-of-days.
-rw-r--r--lisp/gnus/mail-source.el16
1 files changed, 6 insertions, 10 deletions
diff --git a/lisp/gnus/mail-source.el b/lisp/gnus/mail-source.el
index 3befd46620e..93f03be72d0 100644
--- a/lisp/gnus/mail-source.el
+++ b/lisp/gnus/mail-source.el
@@ -591,25 +591,21 @@ Return the number of files that were found."
591If CONFIRM is non-nil, ask for confirmation before removing a file." 591If CONFIRM is non-nil, ask for confirmation before removing a file."
592 (interactive "P") 592 (interactive "P")
593 (require 'gnus-util) 593 (require 'gnus-util)
594 (let* ((high2days (/ 65536.0 60 60 24));; convert high bits to days 594 (let* ((now (current-time))
595 (low2days (/ 1.0 65536.0)) ;; convert low bits to days
596 (diff (if (natnump age) age 30));; fallback, if no valid AGE given 595 (diff (if (natnump age) age 30));; fallback, if no valid AGE given
597 currday files) 596 files)
598 (setq files (directory-files 597 (setq files (directory-files
599 mail-source-directory t 598 mail-source-directory t
600 (concat "\\`" 599 (concat "\\`"
601 (regexp-quote mail-source-incoming-file-prefix))) 600 (regexp-quote mail-source-incoming-file-prefix))))
602 currday (* (car (current-time)) high2days)
603 currday (+ currday (* low2days (nth 1 (current-time)))))
604 (while files 601 (while files
605 (let* ((ffile (car files)) 602 (let* ((ffile (car files))
606 (bfile (replace-regexp-in-string "\\`.*/\\([^/]+\\)\\'" "\\1" 603 (bfile (replace-regexp-in-string "\\`.*/\\([^/]+\\)\\'" "\\1"
607 ffile)) 604 ffile))
608 (filetime (nth 5 (file-attributes ffile))) 605 (filetime (nth 5 (file-attributes ffile))))
609 (fileday (* (car filetime) high2days))
610 (fileday (+ fileday (* low2days (nth 1 filetime)))))
611 (setq files (cdr files)) 606 (setq files (cdr files))
612 (when (and (> (- currday fileday) diff) 607 (when (and (> (time-to-number-of-days (time-subtract now filetime))
608 diff)
613 (if confirm 609 (if confirm
614 (y-or-n-p 610 (y-or-n-p
615 (format-message "\ 611 (format-message "\