summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2020-11-12 17:40:40 +0100
committerJean Felder <jfelder@src.gnome.org>2021-02-23 18:52:11 +0100
commitb0e3c26b9a0f7fdd36032ea823344b29140773a6 (patch)
treef0c348cfaf9ac7f93d556d075c9cea7394c6ee4a
parentc041395ebced1f54af23d46956907ae4fa7f9f77 (diff)
downloadgrilo-plugins-b0e3c26b9a0f7fdd36032ea823344b29140773a6.tar.gz
tracker3: Handle delete events better
These produce unnecessary busywork as resolving a deleted resource will not return any data, and also are mistakenly silenced away since they will end up without a URL. Only the media ID is reliable at that moment, so go with it.
-rw-r--r--src/tracker3/grl-tracker-source-notif.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/tracker3/grl-tracker-source-notif.c b/src/tracker3/grl-tracker-source-notif.c
index 1b8e526..81535a0 100644
--- a/src/tracker3/grl-tracker-source-notif.c
+++ b/src/tracker3/grl-tracker-source-notif.c
@@ -122,7 +122,8 @@ handle_changes (GrlTrackerSourceNotify *self,
if (tracker_notifier_event_get_event_type (event) != tracker_type)
continue;
- if (grl_media_get_url (media) == NULL)
+ if (tracker_type != TRACKER_NOTIFIER_EVENT_DELETE &&
+ grl_media_get_url (media) == NULL)
continue;
g_ptr_array_add (change_list, g_object_ref (media));
@@ -166,8 +167,17 @@ resolve_medias (GrlTrackerChangeBatch *batch)
GrlTrackerSourceNotify *self = batch->notify;
GrlMedia *media = NULL;
- if (batch->cur_media < batch->medias->len)
+ while (batch->cur_media < batch->medias->len) {
+ TrackerNotifierEvent *event = g_ptr_array_index (batch->events, batch->cur_media);
+ /* Resolving a deleted resource will come up empty */
+ if (tracker_notifier_event_get_event_type (event) == TRACKER_NOTIFIER_EVENT_DELETE) {
+ batch->cur_media++;
+ continue;
+ }
+
media = g_ptr_array_index (batch->medias, batch->cur_media);
+ break;
+ }
if (media) {
grl_source_resolve (self->source,