From 564e6918fe36dfbe5964d23a0749a6c180f0544b Mon Sep 17 00:00:00 2001 From: Harald Judt Date: Mon, 16 Mar 2015 19:29:48 +0100 Subject: Fix updating file info for moved files (bug #11008) When a file has been moved, it will trigger a G_FILE_MONITOR_EVENT_MOVED in thunar-folder.c, with the target file saved in other_file. While we reload the folder, that only fetches the info for the target file from the file info cache, which still contains the information of the replaced file. So issue a reload of the target file to update the file information properly, and also a reload of the folder containing the target file if it is not the same as the folder of the source file. --- thunar/thunar-folder.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/thunar/thunar-folder.c b/thunar/thunar-folder.c index c8acc3b..2e0b95b 100644 --- a/thunar/thunar-folder.c +++ b/thunar/thunar-folder.c @@ -698,6 +698,7 @@ thunar_folder_monitor (GFileMonitor *monitor, { ThunarFolder *folder = THUNAR_FOLDER (user_data); ThunarFile *file; + ThunarFile *other_parent; GList *lp; GList list; gboolean restart = FALSE; @@ -738,12 +739,40 @@ thunar_folder_monitor (GFileMonitor *monitor, } else if (lp != NULL) { - /* update/destroy the file */ if (event_type == G_FILE_MONITOR_EVENT_DELETED) - thunar_file_destroy (lp->data); + { + /* destroy the file */ + thunar_file_destroy (lp->data); + } + else if (event_type == G_FILE_MONITOR_EVENT_MOVED) { + /* destroy the old file and update the new one */ thunar_file_destroy (lp->data); + file = thunar_file_get(other_file, NULL); + if (file != NULL && THUNAR_IS_FILE (file)) + { + thunar_file_reload (file); + + /* if source and target folders are different, also tell + the target folder to reload for the changes */ + if (thunar_file_has_parent (file)) + { + other_parent = thunar_file_get_parent (file, NULL); + if (other_parent && + !g_file_equal (thunar_file_get_file(folder->corresponding_file), + thunar_file_get_file(other_parent))) + { + thunar_file_reload (other_parent); + g_object_unref (other_parent); + } + } + + /* drop reference on the other file */ + g_object_unref (file); + } + + /* reload the folder of the source file */ thunar_file_reload (folder->corresponding_file); } else -- 2.3.3