[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master bdb0774: thumbs.el: avoid creating thumbs directory on loading li
From: |
Glenn Morris |
Subject: |
master bdb0774: thumbs.el: avoid creating thumbs directory on loading library |
Date: |
Tue, 16 Feb 2021 15:12:27 -0500 (EST) |
branch: master
commit bdb0774faf250798d043a93e8a7295df924c4c3b
Author: Glenn Morris <rgm@gnu.org>
Commit: Glenn Morris <rgm@gnu.org>
thumbs.el: avoid creating thumbs directory on loading library
* lisp/thumbs.el (thumbs-cleanup-thumbsdir):
Don't create the thumbs directory if it does not exist.
---
lisp/thumbs.el | 35 ++++++++++++++++++-----------------
1 file changed, 18 insertions(+), 17 deletions(-)
diff --git a/lisp/thumbs.el b/lisp/thumbs.el
index 465d097..957940b 100644
--- a/lisp/thumbs.el
+++ b/lisp/thumbs.el
@@ -199,23 +199,24 @@ Create the thumbnails directory if it does not exist."
If the total size of all files in `thumbs-thumbsdir' is bigger than
`thumbs-thumbsdir-max-size', files are deleted until the max size is
reached."
- (let* ((files-list
- (sort
- (mapcar
- (lambda (f)
- (let ((fattribs-list (file-attributes f)))
- `(,(file-attribute-access-time fattribs-list)
- ,(file-attribute-size fattribs-list)
- ,f)))
- (directory-files (thumbs-thumbsdir) t (image-file-name-regexp)))
- (lambda (l1 l2) (time-less-p (car l1) (car l2)))))
- (dirsize (apply '+ (mapcar (lambda (x) (cadr x)) files-list))))
- (while (> dirsize thumbs-thumbsdir-max-size)
- (progn
- (message "Deleting file %s" (cadr (cdar files-list))))
- (delete-file (cadr (cdar files-list)))
- (setq dirsize (- dirsize (car (cdar files-list))))
- (setq files-list (cdr files-list)))))
+ (when (file-directory-p thumbs-thumbsdir)
+ (let* ((files-list
+ (sort
+ (mapcar
+ (lambda (f)
+ (let ((fattribs-list (file-attributes f)))
+ `(,(file-attribute-access-time fattribs-list)
+ ,(file-attribute-size fattribs-list)
+ ,f)))
+ (directory-files (thumbs-thumbsdir) t (image-file-name-regexp)))
+ (lambda (l1 l2) (time-less-p (car l1) (car l2)))))
+ (dirsize (apply '+ (mapcar (lambda (x) (cadr x)) files-list))))
+ (while (> dirsize thumbs-thumbsdir-max-size)
+ (progn
+ (message "Deleting file %s" (cadr (cdar files-list))))
+ (delete-file (cadr (cdar files-list)))
+ (setq dirsize (- dirsize (car (cdar files-list))))
+ (setq files-list (cdr files-list))))))
;; Check the thumbnail directory size and clean it if necessary.
(when thumbs-thumbsdir-auto-clean
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master bdb0774: thumbs.el: avoid creating thumbs directory on loading library,
Glenn Morris <=