From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Shingo Tanaka Newsgroups: gmane.emacs.bugs Subject: bug#37922: Acknowledgement (26.3; move-file-to-trash puts wrong trash file name at name collision) Date: Sun, 27 Oct 2019 10:51:01 +0900 Message-ID: <87pnijufay.wl-shingo.fg8@gmail.com> References: Mime-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="124628"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM/1.14.9 (=?UTF-8?Q?Goj=C5=8D?=) APEL/10.8 EasyPG/1.0.0 Emacs/26 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) To: 37922@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Oct 27 02:52:24 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iOXjE-000WHj-E8 for geb-bug-gnu-emacs@m.gmane.org; Sun, 27 Oct 2019 02:52:24 +0100 Original-Received: from localhost ([::1]:43748 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iOXjC-00026r-JY for geb-bug-gnu-emacs@m.gmane.org; Sat, 26 Oct 2019 21:52:22 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48365) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iOXiu-00022m-I2 for bug-gnu-emacs@gnu.org; Sat, 26 Oct 2019 21:52:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iOXit-0004AB-F7 for bug-gnu-emacs@gnu.org; Sat, 26 Oct 2019 21:52:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60980) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iOXit-0004A6-9U for bug-gnu-emacs@gnu.org; Sat, 26 Oct 2019 21:52:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iOXis-0000Tt-67 for bug-gnu-emacs@gnu.org; Sat, 26 Oct 2019 21:52:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Shingo Tanaka Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 27 Oct 2019 01:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 37922 X-GNU-PR-Package: emacs Original-Received: via spool by 37922-submit@debbugs.gnu.org id=B37922.15721410741784 (code B ref 37922); Sun, 27 Oct 2019 01:52:02 +0000 Original-Received: (at 37922) by debbugs.gnu.org; 27 Oct 2019 01:51:14 +0000 Original-Received: from localhost ([127.0.0.1]:41568 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iOXi5-0000Si-W1 for submit@debbugs.gnu.org; Sat, 26 Oct 2019 21:51:14 -0400 Original-Received: from mail-pf1-f179.google.com ([209.85.210.179]:38224) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iOXi2-0000SU-SM for 37922@debbugs.gnu.org; Sat, 26 Oct 2019 21:51:12 -0400 Original-Received: by mail-pf1-f179.google.com with SMTP id c13so4259630pfp.5 for <37922@debbugs.gnu.org>; Sat, 26 Oct 2019 18:51:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:from:to:subject:in-reply-to:references:user-agent :mime-version; bh=1xhi4ZuRroMOADE7T3H1nNMknLGOW62Rf1kEWqS0JDI=; b=NuFfetZPFB4JZihzJxDDnJuQmCDKHg5v9DcTMZbXLWlpva1Yv5aa4E1m/xV1GuDRsj CUND93skHGFg3fT9UpzpajRCc8VFevxgQMkBqcmdrrX1DnJKmMyvaXmshJpuyV3y5qbM K3WfspF8sYaqg0kKV9auQKxZrMceVrfDGomqKpb+lZ4wKFwllULeeI9+7DIwYg+lVz+Y kTPPq4f1SPo2/k/HnggvdQJzwh24b8h0rTBZ7u0QFrIEPPKQm7nkaBxA98Fd8FYpvujz Oru6F3iouhUQ8CS1H5EWaT7wUKsR308HMb0v8jeyb3R40k5pTsGQm5uMSG9yOyUI5H/l J/ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:from:to:subject:in-reply-to :references:user-agent:mime-version; bh=1xhi4ZuRroMOADE7T3H1nNMknLGOW62Rf1kEWqS0JDI=; b=aG1APIIwdCeBgLcxlRzhvt/5GaMtKfK8qmaoJqOjpD9qqN3K86qCXgfZStVJTf+i+r 209RivR7mlJ2Bu3P1T5mwee3mGFONmUvyS1rf756uo30MtpI7n7hp1zjCGbbrDO8ZUK9 YTSDElJ7WHo78gFpLnMnRzy4s45RkQkACkTlu2k4diQadQVkP+U/aG/0Vi8fIEhrLCuV PxG+Avs4Zi8Z5GmD+cW1acumFndF/r1HkYsl9SEM2D5sXGQs8VKNn9xP1bMY3M2+fACA hcrYIFc8MSYMy2SQGePSYoc5MkgwY07wnHdrKGfECQ5nHXqWSRS5QkkfP4m275c7EOwM 80uQ== X-Gm-Message-State: APjAAAVbmmhOCIRvw4LouZ3jSXzUgG6gt9n8xlLURPJkx5Qi40pVu+1f nzYgGjWJgaOjB9v4o5jb0SayeBBw X-Google-Smtp-Source: APXvYqzihrNdK8tG6jP48H52Tyq3TprbFLbbFSyEgRBlwmyeSa4B9oY2LGfg1F/y/ajbcO1orFQVvg== X-Received: by 2002:a63:d703:: with SMTP id d3mr13252414pgg.102.1572141064288; Sat, 26 Oct 2019 18:51:04 -0700 (PDT) Original-Received: from P8E197343H.gmail.com ([240f:36:d353:1:3467:c0b7:d1f7:5162]) by smtp.gmail.com with ESMTPSA id t11sm6260659pjy.10.2019.10.26.18.51.03 for <37922@debbugs.gnu.org> (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Oct 2019 18:51:03 -0700 (PDT) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:170227 Archived-At: # Resending it as I sent the original mail in HTML format by mistake... Hi, When delete-by-moving-to-trash is t and system-move-file-to-trash is not defined, move-file-to-trash moves the deleted file to system trash can following freedesktop.org trash can specification. In this condition, when a file is deleted and it has the same name as the one of an already deleted file in trash can, move-file-to-trash generates another file name by using make-temp-file to avoid the name collision. Unfortunatelly, it does the naming in a wrong way. For example, when 2 "hoge.txt" are deleted, expected files are like: /home/myusername/.local/share/Trash/files: -rw-rw-rw- 1 myusername 10 2019-10-25 20:00 hoge.txt -rw-rw-rw- 1 myusername 10 2019-10-25 20:00 hoge.txtwmWP0h /home/myusername/.local/share/Trash/info: -rw-rw-rw- 1 myusername 75 2019-10-25 20:00 hoge.txt.trashinfo -rw------- 1 myusername 75 2019-10-25 20:00 hoge.txtwmWP0h.trashinfo However, the reality is the 2nd trash file in files directory is named wrongly with ".trashinfo" suffix like: /home/myusername/.local/share/Trash/files: -rw-rw-rw- 1 myusername 10 2019-10-25 20:00 hoge.txt -rw-rw-rw- 1 myusername 10 2019-10-25 20:00 hoge.txtwmWP0h.trashinfo ^^^^^^^^^ /home/myusername/.local/share/Trash/info: -rw-rw-rw- 1 myusername 75 2019-10-25 20:00 hoge.txt.trashinfo -rw------- 1 myusername 75 2019-10-25 20:00 hoge.txtwmWP0h.trashinfo Here is a potential patch. --- files.el.original 2019-09-17 05:14:45.000000000 +0900 +++ files.el 2019-10-25 20:52:13.899138800 +0900 @@ -7408,7 +7408,8 @@ (setq info-fn (make-temp-file (expand-file-name files-base trash-info-dir) nil ".trashinfo")) - (setq files-base (file-name-nondirectory info-fn)) + (setq files-base (substring (file-name-nondirectory info-fn) + 0 (- (length ".trashinfo")))) (write-region nil nil info-fn nil 'quiet info-fn))) ;; Finally, try to move the file to the trashcan. (let ((delete-by-moving-to-trash nil) --- Shingo Tanaka