[tracker-miners/wip/carlosg/monitor-thread: 2/5] libtracker-miner: Move early cancellation of directory monitors




commit f5af354bb2ce520a9ea99e3da7d3cf1e29e1cb8b
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Mar 7 15:30:16 2021 +0100

    libtracker-miner: Move early cancellation of directory monitors
    
    The intent is to add a thread to manage monitors and their events,
    this will be more convenient then, as this should happen in that
    thread before event emission.

 src/libtracker-miner/tracker-monitor.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-monitor.c b/src/libtracker-miner/tracker-monitor.c
index 459008978..e30826450 100644
--- a/src/libtracker-miner/tracker-monitor.c
+++ b/src/libtracker-miner/tracker-monitor.c
@@ -595,16 +595,6 @@ emit_signal_for_event (TrackerMonitor    *monitor,
                        GFile             *file,
                        GFile             *other_file)
 {
-       /* Note that in any case we should be moving the monitors
-        * here to the new place, as the new place may be ignored.
-        * We should leave this to the upper layers. But one thing
-        * we must do is actually CANCEL all these monitors. */
-       if (is_directory &&
-           (type == G_FILE_MONITOR_EVENT_MOVED ||
-            type == G_FILE_MONITOR_EVENT_DELETED)) {
-               monitor_cancel_recursively (monitor, file);
-       }
-
        switch (type) {
        case G_FILE_MONITOR_EVENT_CREATED:
                g_signal_emit (monitor,
@@ -776,6 +766,17 @@ monitor_event_cb (GFileMonitor      *file_monitor,
                }
        }
 
+       /* Note that in any case we should be moving the monitors
+        * here to the new place, as the new place may be ignored.
+        * We should leave this to the upper layers. But one thing
+        * we must do is actually CANCEL all these monitors. */
+       if (is_directory &&
+           (event_type == G_FILE_MONITOR_EVENT_RENAMED ||
+            event_type == G_FILE_MONITOR_EVENT_MOVED_IN ||
+            event_type == G_FILE_MONITOR_EVENT_DELETED)) {
+               monitor_cancel_recursively (monitor, file);
+       }
+
        switch (event_type) {
        case G_FILE_MONITOR_EVENT_CREATED:
        case G_FILE_MONITOR_EVENT_CHANGED:


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