Fix problem of trashing files to an inconsistent trash directory
* lisp/files.el (move-file-to-trash): Allow moving files to trash even if there's a file in trash with the same name (but no entry in info) (bug#47135).
This commit is contained in:
parent
0aad4d134f
commit
a5197e2240
1 changed files with 16 additions and 3 deletions
|
@ -7858,9 +7858,22 @@ Otherwise, trash FILENAME using the freedesktop.org conventions,
|
|||
|
||||
;; Make a .trashinfo file. Use O_EXCL, as per trash-spec 1.0.
|
||||
(let* ((files-base (file-name-nondirectory fn))
|
||||
(info-fn (expand-file-name
|
||||
(overwrite nil)
|
||||
info-fn)
|
||||
;; We're checking further down whether the info file
|
||||
;; exists, but the file name may exist in the trash
|
||||
;; directory even if there is no info file for it.
|
||||
(when (file-exists-p
|
||||
(expand-file-name files-base trash-files-dir))
|
||||
(setq overwrite t
|
||||
files-base (file-name-nondirectory
|
||||
(make-temp-file
|
||||
(expand-file-name
|
||||
files-base trash-files-dir)))))
|
||||
(setq info-fn (expand-file-name
|
||||
(concat files-base ".trashinfo")
|
||||
trash-info-dir)))
|
||||
trash-info-dir))
|
||||
;; Re-check the existence (sort of).
|
||||
(condition-case nil
|
||||
(write-region nil nil info-fn nil 'quiet info-fn 'excl)
|
||||
(file-already-exists
|
||||
|
@ -7876,7 +7889,7 @@ Otherwise, trash FILENAME using the freedesktop.org conventions,
|
|||
;; Finally, try to move the file to the trashcan.
|
||||
(let ((delete-by-moving-to-trash nil)
|
||||
(new-fn (expand-file-name files-base trash-files-dir)))
|
||||
(rename-file fn new-fn)))))))))
|
||||
(rename-file fn new-fn overwrite)))))))))
|
||||
|
||||
(defsubst file-attribute-type (attributes)
|
||||
"The type field in ATTRIBUTES returned by `file-attributes'.
|
||||
|
|
Loading…
Add table
Reference in a new issue