filesystemmodel: Ignore changes on the parent directory
authorCorey Berla <corey@berla.me>
Mon, 15 May 2023 20:10:21 +0000 (13:10 -0700)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 5 Jun 2023 11:50:34 +0000 (07:50 -0400)
The filesystemmodel tracks changes and additions to child files
through G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED.  This event will also
occur if the parent directory is changed.  Since the parent directory
doesn't exist in the model, it creates a non-existent item.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/4233
gtk/gtkfilesystemmodel.c

index 6dca1cb999cf549bb0921d0615a9043dc2ce6ab8..624b9a0c74fd0492fb176849db7426a3ddb023b3 100644 (file)
@@ -748,7 +748,9 @@ gtk_file_system_model_monitor_change (GFileMonitor *      monitor,
       case G_FILE_MONITOR_EVENT_CREATED:
       case G_FILE_MONITOR_EVENT_CHANGED:
       case G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED:
-        /* We can treat all of these the same way */
+        if (g_file_equal (file, model->dir))
+          return;
+        /* We can treat all children the same way */
         g_file_query_info_async (file,
                                  model->attributes,
                                  G_FILE_QUERY_INFO_NONE,