summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lisp/image/image-dired-util.el25
-rw-r--r--test/lisp/image/image-dired-util-tests.el14
2 files changed, 28 insertions, 11 deletions
diff --git a/lisp/image/image-dired-util.el b/lisp/image/image-dired-util.el
index f8e81d2e8d7..e7d116d90ba 100644
--- a/lisp/image/image-dired-util.el
+++ b/lisp/image/image-dired-util.el
@@ -85,19 +85,22 @@ See also `image-dired-thumbnail-storage'."
;; Maintained for backwards compatibility:
(eq 'use-image-dired-dir image-dired-thumbnail-storage))
(let* ((f (expand-file-name file))
- (hash
- (md5 (file-name-as-directory (file-name-directory f)))))
- (format "%s%s%s.thumb.%s"
- (file-name-as-directory (expand-file-name (image-dired-dir)))
- (file-name-base f)
- (if hash (concat "_" hash) "")
- (file-name-extension f))))
+ (hash (md5 (file-name-as-directory (file-name-directory f)))))
+ (expand-file-name
+ (format "%s%s.thumb.%s"
+ (file-name-base f)
+ (if hash (concat "_" hash) "")
+ (file-name-extension f))
+ (image-dired-dir))))
((eq 'per-directory image-dired-thumbnail-storage)
(let ((f (expand-file-name file)))
- (format "%s.image-dired/%s.thumb.%s"
- (file-name-directory f)
- (file-name-base f)
- (file-name-extension f))))))
+ (expand-file-name
+ (format "%s.thumb.%s"
+ (file-name-base f)
+ (file-name-extension f))
+ (expand-file-name
+ ".image-dired"
+ (file-name-directory f)))))))
(defvar image-dired-thumbnail-buffer "*image-dired*"
"Image-Dired's thumbnail buffer.")
diff --git a/test/lisp/image/image-dired-util-tests.el b/test/lisp/image/image-dired-util-tests.el
index 39862fc6faa..9fb457dd36e 100644
--- a/test/lisp/image/image-dired-util-tests.el
+++ b/test/lisp/image/image-dired-util-tests.el
@@ -28,6 +28,10 @@
(ert-deftest image-dired-thumb-name/standard ()
(let ((image-dired-thumbnail-storage 'standard))
(should (file-name-absolute-p (image-dired-thumb-name "foo.jpg")))
+ (should (file-name-absolute-p (image-dired-thumb-name "/tmp/foo.jpg")))
+ (should (equal
+ (file-name-directory (image-dired-thumb-name "foo.jpg"))
+ (file-name-directory (image-dired-thumb-name "/tmp/foo.jpg"))))
(should (string-search (xdg-cache-home)
(image-dired-thumb-name "foo.jpg")))
(should (string-match (rx (in "0-9a-f") ".png")
@@ -39,6 +43,10 @@
(let ((image-dired-dir dir)
(image-dired-thumbnail-storage 'image-dired))
(should (file-name-absolute-p (image-dired-thumb-name "foo.jpg")))
+ (should (file-name-absolute-p (image-dired-thumb-name "/tmp/foo.jpg")))
+ (should (equal
+ (file-name-directory (image-dired-thumb-name "foo.jpg"))
+ (file-name-directory (image-dired-thumb-name "/tmp/foo.jpg"))))
(should (equal (file-name-nondirectory
;; The checksum is based on the directory name.
(image-dired-thumb-name "/some/path/foo.jpg"))
@@ -47,6 +55,12 @@
(ert-deftest image-dired-thumb-name/per-directory ()
(let ((image-dired-thumbnail-storage 'per-directory))
(should (file-name-absolute-p (image-dired-thumb-name "foo.jpg")))
+ (should (file-name-absolute-p (image-dired-thumb-name "/tmp/foo.jpg")))
+ (should (equal
+ (file-name-nondirectory (image-dired-thumb-name "foo.jpg"))
+ (file-name-nondirectory (image-dired-thumb-name "/tmp/foo.jpg"))))
+ (should (equal (file-name-split (image-dired-thumb-name "/tmp/foo.jpg"))
+ '("" "tmp" ".image-dired" "foo.thumb.jpg")))
(should (equal (file-name-nondirectory
(image-dired-thumb-name "foo.jpg"))
"foo.thumb.jpg"))))