Moving a non-empty directory resets its modification time
Steps to reproduce:
- Create a directory and a file inside.
- Set mtime of the directory to some well-known value.
- Move the directory to another place (remote or local).
Expected result: The directory mtime stays the same.
Actual result: The directory mtime is the current time.
The issue doesn't happen on copy or if the directory is empty.
The relevant code is copy_move_directory
in src/nautilus-file-operations.c. Its algorithm is as follows:
- Create the destination directory.
- Move the old directory contents recursively.
-
g_file_copy_attributes
from the old directory to the new. - Delete the old directory.
The issue is that step 2 actually leads to modification of the old directory's mtime, so g_file_copy_attributes
copies the attributes that are already lost at that point.
The fix could be to save the old directory's attributes before step 2. For that we'll need to get change glib!1449 (merged) into glib to be able to split g_file_copy_attributes
into two stages: before step 2 and after. If this direction sounds right, I can work on a patch for nautilus.