GNU bug report logs - #61394
30.0.50; [PATCH] Image-dired thumb name based on content

Previous Next

Package: emacs;

Reported by: Manuel Giraud <manuel <at> ledu-giraud.fr>

Date: Thu, 9 Feb 2023 19:08:02 UTC

Severity: normal

Tags: patch

Found in version 30.0.50

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Eli Zaretskii <eliz <at> gnu.org>
To: Manuel Giraud <manuel <at> ledu-giraud.fr>
Cc: contovob <at> tcd.ie, 61394 <at> debbugs.gnu.org
Subject: bug#61394: 30.0.50; [PATCH] Image-dired thumb name based on content
Date: Sat, 11 Feb 2023 11:50:33 +0200
> Cc: 61394 <at> debbugs.gnu.org
> Date: Fri, 10 Feb 2023 19:46:02 +0100
> From:  Manuel Giraud via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
> 
> +(defun image-dired-content-sha1 (filename)
> +  "Compute the SHA-1 of a part of FILENAME."

Not "part of FILENAME", but "the first 4KiB of FILENAME's contents".

Btw, using only the first 4KiB would mean a collision is still
possible, albeit rarely, right?  So your use case of having all the
thumbnails in the same directory could sometimes fail, right?

> +  (with-temp-buffer
> +    (insert-file-contents filename nil 0 4096)

Please use insert-file-contents-literally here.  It should be much
faster, and we only care about the file's bytestream anyway.

>  (defun image-dired-thumb-name (file)
>    "Return absolute file name for thumbnail FILE.
>  Depending on the value of `image-dired-thumbnail-storage', the
>  file name of the thumbnail will vary:
> -- For `use-image-dired-dir', make a SHA1-hash of the image file's
> -  directory name and add that to make the thumbnail file name
> -  unique.
> +- For `image-dired', make a SHA1-hash of some of the image file.
>  - For `per-directory' storage, just add a subdirectory.
>  - For `standard' storage, produce the file name according to the
>    Thumbnail Managing Standard.  Among other things, an MD5-hash

This doc string "needs work".  Could you please fix it as part of the
patch, even though most of the problems are not due to this patch?  In
any case, please either say here that only the first 4KiB of the file's
contents are SHA1-hashed or include a link to the new function.




This bug report was last modified 1 year and 290 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.