;; 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.")
(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")
(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"))
(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"))))