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

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

bug#37922: closed (26.3; move-file-to-trash puts wrong trash file name a


From: GNU bug Tracking System
Subject: bug#37922: closed (26.3; move-file-to-trash puts wrong trash file name at name collision)
Date: Sat, 16 Nov 2019 12:57:01 +0000

Your message dated Sat, 16 Nov 2019 14:56:37 +0200
with message-id <address@hidden>
and subject line Re: bug#37922: 26.3; move-file-to-trash puts wrong trash file 
name at name collision
has caused the debbugs.gnu.org bug report #37922,
regarding 26.3; move-file-to-trash puts wrong trash file name at name collision
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden.)


-- 
37922: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=37922
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: 26.3; move-file-to-trash puts wrong trash file name at name collision Date: Fri, 25 Oct 2019 22:59:28 +0900
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.  Unfortunately, it does put a wrong name with suffix ".trashinfo".

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

--- End Message ---
--- Begin Message --- Subject: Re: bug#37922: 26.3; move-file-to-trash puts wrong trash file name at name collision Date: Sat, 16 Nov 2019 14:56:37 +0200
> From: Shingo Tanaka <address@hidden>
> Date: Fri, 25 Oct 2019 22:59:28 +0900
> 
> 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.
> Unfortunately, it does put a wrong name with suffix ".trashinfo".
> 
> 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.

Thanks, I installed this.


--- End Message ---

reply via email to

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