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

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

bug#5436: 23.1.91; Deleting directories causes unusable file layout in f


From: David De La Harpe Golden
Subject: bug#5436: 23.1.91; Deleting directories causes unusable file layout in freedesktop trashcan
Date: Mon, 25 Jan 2010 23:33:06 +0000
User-agent: Mozilla-Thunderbird 2.0.0.22 (X11/20091109)

Chong Yidong wrote:
I don't think it's wise to make this drastic change to rename-file so
late in the release process.  Is it necessary for fixing this particular
issue (Bug#5436)?  If not, we should only apply the delete-directory
change.

Hmm. I suppose strictly it is not necessary to fix the precise issue - partial or total failure to delete isn't the same as successfully deleting but with a bad layout in the trash.

Just the delete-directory change _is_ a marked improvement, since it does mean that the subsequent failure mode when you try to delete from a different filesystem to your /home is less obnoxious:

- Without the delete-directory change, the xdev behaviour is very bad indeed:

Say you have /usr/local and /home on different filesystems, as is quite common, and you delete-directory a tree in /usr/local with delete-by-moving-to-trash on - first, a few leaf regular files from a dir of the tree may be moved to trash (flattened), and only a bit later the operation will fail, when the first directory rename is attempted. Leaving behind a (maybe large) tree that might look untouched to casual inspection following an apparently-failed deletion operation, but actually with a few files missing, moved to the trash. Eek.

- With the delete-directory change but without the rename-file change (or something else*), deleting from /usr/local will still fail, just pretty much immediately instead of making such a mess.


* There are also alternatives to expanding rename-file to handle xdev directory renames:

1. move-file-to-trash could just use a copy-directory and then a delete-directory itself in the case it is passed a directory, which would be obviously less efficient in the same-filesystem case, but wouldn't fail nearly as easily as the untouched situation. If it's easy to tell if directories are on the same filesystem from within elisp (which I haven't looked into yet), it could use rename-file where possible.

+++ That approach might squeeze in? copy-directory and delete-directory in themselves aren't as new.


2. could introduce a separate function capable of renaming directories xdev?

After all, copy-file and copy-directory and delete-file and delete-directory are separated. move-file-to-trash could easily call, say, a "rename-directory" for directories and rename-file for files. Of course rename-file does work _sometimes_ on directories, just not xdev (someone apparently hacked it to work xdev for files at some stage...) - I suppose a note could be added to the rename-file docstring saying that if you want directory renames that work xdev you should really use rename-directory.

A separate rename-directory function might facilitate dealing with complex cases.

(And/or there could be separate move-file-to-trash and move-directory-to-trash functions, or for naming regularity, move-file-to-trash could still handle both but be renamed move-to-trash...)


















reply via email to

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