bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Eli Zaretskii
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@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@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.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]