Subject: Re: bug#61394: 30.0.50; [PATCH] Image-dired thumb name based on content

From: Manuel Giraud <[email-masked]>
Date: Thu, 27 Jul 2023 23:30:29 +0200

Eli Zaretskii <[email-masked]> writes:

[...]

> Thanks, installed.  But now 1 set in image-dired-util-tests fails; it
> sounds like the method of producing per-directory thumbnails has
> changed, and now produces a SHA-1 hash?  Can you please look into
> fixing that test?

Ok, I think this patch should do.
-- 
Manuel Giraud
>From 1460fb462300aac70faf99724efe126c72ad5fe6 Mon Sep 17 00:00:00 2001
From: Manuel Giraud <[email-masked]>
Date: Thu, 27 Jul 2023 23:26:30 +0200
Subject: [PATCH] Fix test after 83b6a8a5147

---
 test/lisp/image/image-dired-util-tests.el | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/test/lisp/image/image-dired-util-tests.el b/test/lisp/image/image-dired-util-tests.el
index 1f3747a82b1..273a32d5dbb 100644
--- a/test/lisp/image/image-dired-util-tests.el
+++ b/test/lisp/image/image-dired-util-tests.el
@@ -57,20 +57,23 @@ image-dired-thumb-name/image-dired
                      "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")))
+  (let ((image-dired-thumbnail-storage 'per-directory)
+        (rel-path "foo.jpg")
+        (abs-path "/tmp/foo.jpg")
+        (hash-name (concat (sha1 "foo.jpg") ".jpg")))
+    (should (file-name-absolute-p (image-dired-thumb-name rel-path)))
+    (should (file-name-absolute-p (image-dired-thumb-name abs-path)))
     (should (equal
-             (file-name-nondirectory (image-dired-thumb-name "foo.jpg"))
-             (file-name-nondirectory (image-dired-thumb-name "/tmp/foo.jpg"))))
+             (file-name-nondirectory (image-dired-thumb-name rel-path))
+             (file-name-nondirectory (image-dired-thumb-name abs-path))))
     ;; The cdr below avoids the system dependency in the car of the
     ;; list returned by 'file-name-split': it's "" on Posix systems,
     ;; but the drive letter on MS-Windows.
     (should (equal (cdr (file-name-split
-                         (image-dired-thumb-name "/tmp/foo.jpg")))
-                   '("tmp" ".image-dired" "foo.jpg.thumb.jpg")))
+                         (image-dired-thumb-name abs-path)))
+                   (list "tmp" ".image-dired" hash-name)))
     (should (equal (file-name-nondirectory
-                    (image-dired-thumb-name "foo.jpg"))
-                   "foo.jpg.thumb.jpg"))))
+                    (image-dired-thumb-name rel-path))
+                   hash-name))))
 
 ;;; image-dired-util-tests.el ends here
-- 
2.40.0