[tracker-miners/wip/carlosg/sparql-buffer-errors] libtracker-miner: Always return task array on TrackerSparqlBuffer




commit 9523e6972523533d599958192ea57e6e281ef264
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Sep 28 13:31:54 2021 +0200

    libtracker-miner: Always return task array on TrackerSparqlBuffer
    
    This used to be the behavior (including on errors) as we want to tag
    file(s) causing this as failed, in order to ease bug reports. This
    behavior broke in commit 7336faa675e as it started returning either
    an error or the task array.
    
    Always return both things here, so we can keep the previous behavior.
    
    Fixes: https://gitlab.gnome.org/GNOME/tracker-miners/-/issues/201
    Related: https://gitlab.gnome.org/GNOME/tracker-miners/-/issues/199

 src/libtracker-miner/tracker-sparql-buffer.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
---
diff --git a/src/libtracker-miner/tracker-sparql-buffer.c b/src/libtracker-miner/tracker-sparql-buffer.c
index b7f5d2273..b3ff07bd9 100644
--- a/src/libtracker-miner/tracker-sparql-buffer.c
+++ b/src/libtracker-miner/tracker-sparql-buffer.c
@@ -204,6 +204,9 @@ batch_execute_cb (GObject      *object,
        if (!tracker_batch_execute_finish (TRACKER_BATCH (object),
                                           result,
                                           &error)) {
+               g_task_set_task_data (update_data->async_task,
+                                     g_ptr_array_ref (update_data->tasks),
+                                     (GDestroyNotify) g_ptr_array_unref);
                g_task_return_error (update_data->async_task, error);
        } else {
                g_task_return_pointer (update_data->async_task,
@@ -407,11 +410,18 @@ tracker_sparql_buffer_flush_finish (TrackerSparqlBuffer  *buffer,
                                     GAsyncResult         *res,
                                     GError              **error)
 {
+       GPtrArray *tasks;
+
        g_return_val_if_fail (TRACKER_IS_SPARQL_BUFFER (buffer), NULL);
        g_return_val_if_fail (G_IS_ASYNC_RESULT (res), NULL);
        g_return_val_if_fail (!error || !*error, NULL);
 
-       return g_task_propagate_pointer (G_TASK (res), error);
+       tasks = g_task_propagate_pointer (G_TASK (res), error);
+
+       if (!tasks)
+               tasks = g_task_get_task_data (G_TASK (res));
+
+       return tasks;
 }
 
 TrackerSparqlBufferState


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