From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#61394: 30.0.50; [PATCH] Image-dired thumb name based on content Date: Sat, 11 Feb 2023 11:50:33 +0200 Message-ID: <83ilg8jzti.fsf@gnu.org> References: <874jruy7xx.fsf@ledu-giraud.fr> <87ttztk0yw.fsf@tcd.ie> <87v8k9s6j9.fsf@ledu-giraud.fr> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13551"; mail-complaints-to="usenet@ciao.gmane.io" Cc: contovob@tcd.ie, 61394@debbugs.gnu.org To: Manuel Giraud Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Feb 11 10:52:19 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pQmYN-0003Hb-ES for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 11 Feb 2023 10:52:19 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pQmY9-0008Sn-CG; Sat, 11 Feb 2023 04:52:05 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pQmY6-0008SQ-Ua for bug-gnu-emacs@gnu.org; Sat, 11 Feb 2023 04:52:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pQmY6-0004sC-MW for bug-gnu-emacs@gnu.org; Sat, 11 Feb 2023 04:52:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pQmY6-0003cs-Bk for bug-gnu-emacs@gnu.org; Sat, 11 Feb 2023 04:52:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 11 Feb 2023 09:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61394 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 61394-submit@debbugs.gnu.org id=B61394.167610907513878 (code B ref 61394); Sat, 11 Feb 2023 09:52:02 +0000 Original-Received: (at 61394) by debbugs.gnu.org; 11 Feb 2023 09:51:15 +0000 Original-Received: from localhost ([127.0.0.1]:38745 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pQmXL-0003bm-1F for submit@debbugs.gnu.org; Sat, 11 Feb 2023 04:51:15 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:52724) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pQmXG-0003bV-Sv for 61394@debbugs.gnu.org; Sat, 11 Feb 2023 04:51:13 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pQmXA-0004dU-RF; Sat, 11 Feb 2023 04:51:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=MiX6sbF9e2nM4KUVPb2pUx2ONYiIRMrNIGQLzWDOeoE=; b=O3BHcya8gtkp BU165rdbsgu87+BOw8aLuLAkNcXYXxdj0C7lh8o/RHhbBGtzq3l901JtLLRTyZu3ORwBGc+qje00O tVfg5zld6wFnHJUUk6VTnk9HjGO1Tnph3UDs6dGeQDXNpH7yKhUhyIEDokG4Cj+4mz05ioTtRIZXG CVLtDm/MwVOHnxiCPnpVyGt/MDZYuJW0awTzd1KbXDhEXSgpRQsMsFy9dDK59XlYIvDPjZrjDdeCl nerDuFDigCvDsOKCXrKc4W2Eb7tezE/Fp6PPbThVG3p+EpLpuG5i73crCc8S5TSJRGBVbKvpT5PM3 F5CaAJQAFx49ehquKjdnaQ==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pQmX9-0001w6-Vu; Sat, 11 Feb 2023 04:51:04 -0500 In-Reply-To: <87v8k9s6j9.fsf@ledu-giraud.fr> (bug-gnu-emacs@gnu.org) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:255323 Archived-At: > 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" > > +(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.