! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
Renaming a file from another file manager, file disappears in Thunar window
Status:
RESOLVED: FIXED

Comments

Description Matt32 2015-01-07 21:34:26 CET
 
Comment 1 Matt32 2015-01-07 21:42:54 CET
When renaming a file from $HOME directory with midnight commander, it will disappear almost immediately in Thunar window but the renamed file does not show up.

Steps to reproduce the bug:
- Open Thunar to $HOME
- In a terminal, use 'mc' to rename a file in $HOME directory
- The file disappears in Thunar window
- The file with the new name does not show up in Thunar window.

The same test will work with Caja (MATE Desktop) file manager.
Comment 2 Matt32 2015-01-11 21:59:27 CET
diff --git a/thunar/thunar-folder.c b/thunar/thunar-folder.c
index bc1dcdf..809d5f0 100644
--- a/thunar/thunar-folder.c
+++ b/thunar/thunar-folder.c
@@ -555,7 +555,7 @@ thunar_folder_finished (ExoJob       *job,
 
   /* add us to the file alteration monitor */
   folder->monitor = g_file_monitor_directory (thunar_file_get_file (folder->corresponding_file),
-                                              G_FILE_MONITOR_NONE, NULL, NULL);
+                                              G_FILE_MONITOR_SEND_MOVED, NULL, NULL);
   if (G_LIKELY (folder->monitor != NULL))
     g_signal_connect (folder->monitor, "changed", G_CALLBACK (thunar_folder_monitor), folder);
 
@@ -741,6 +741,11 @@ thunar_folder_monitor (GFileMonitor     *monitor,
           /* update/destroy the file */
           if (event_type == G_FILE_MONITOR_EVENT_DELETED)
             thunar_file_destroy (lp->data);
+          else if (event_type == G_FILE_MONITOR_EVENT_MOVED)
+            {
+              thunar_file_destroy (lp->data);
+              thunar_file_reload (folder->corresponding_file);
+            }
           else
             {
 #if DEBUG_FILE_CHANGES
Comment 3 Landry Breuil editbugs 2015-01-11 22:33:47 CET
I'm not an expert in thunar's internals but that fix seems to make sense to me - did you test it in various different usecases to ensure it didnt cause regressions ?
Comment 4 Peter de Ridder editbugs 2015-01-13 20:35:05 CET
This problem is triggered by the fact that the ThunarFile monitors the file with G_FILE_MONITOR_SEND_MOVED. For some reason the remove the created signal to the folder. The gio docs don't go into this in detail as this is probably backend related.
Im not sure if this it the right solution, especially the fact that it reloads the whole directory
Comment 5 Landry Breuil editbugs 2015-01-13 20:50:28 CET
Fwiw, i cant reproduce it on OpenBSD where gio uses the kqueue backend, glib 2.42.1. When i rename a file from the terminal, it is correctly displayed with the new name in thunar.
Comment 6 Peter de Ridder editbugs 2015-01-13 23:21:03 CET
For the inotify backend is already reported in the upstream:
https://bugzilla.gnome.org/show_bug.cgi?id=742849

Some testing with the kqueue backend shows that the G_FILE_MONITOR_SEND_MOVED flag is ignored for file monitoring and G_FILE_MONITOR_EVENT_MOVED is given even without that flag set, for folders this flag works as expected. So for Thunar this is fine.

Bug #11430

Reported by:
Matt32
Reported on: 2015-01-07
Last modified on: 2015-01-31

People

Assignee:
Jannis Pohlmann
CC List:
5 users

Version

Attachments

Additional information