[tracker] libtracker-direct: Implement update_array_async()
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] libtracker-direct: Implement update_array_async()
- Date: Tue, 14 Nov 2017 22:24:28 +0000 (UTC)
commit 5eede395c234555d1892275ba2959ac0b0d851ef
Author: Carlos Garnacho <carlosg gnome org>
Date: Mon Oct 16 11:46:38 2017 +0200
libtracker-direct: Implement update_array_async()
This doesn't yield as many benefits as it does bring on the DBus backend,
but still worth implementing for consistence.
src/libtracker-direct/tracker-direct.vala | 33 +++++++++++++++++++++++++++++
1 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/src/libtracker-direct/tracker-direct.vala b/src/libtracker-direct/tracker-direct.vala
index 06c6523..6c841a2 100644
--- a/src/libtracker-direct/tracker-direct.vala
+++ b/src/libtracker-direct/tracker-direct.vala
@@ -337,6 +337,39 @@ public class Tracker.Direct.Connection : Tracker.Sparql.Connection, AsyncInitabl
return task.blank_nodes;
}
+ public async override GenericArray<Sparql.Error?>? update_array_async (string[] sparql, int priority
= GLib.Priority.DEFAULT, Cancellable? cancellable = null) throws Sparql.Error, GLib.Error, GLib.IOError,
DBusError {
+ var combined_query = new StringBuilder ();
+ var n_updates = sparql.length;
+ int i;
+
+ for (i = 0; i < n_updates; i++)
+ combined_query.append (sparql[i]);
+
+ var task = new UpdateTask (combined_query.str, priority, cancellable);
+ task.callback = update_array_async.callback;
+ update_queue.push (task);
+ yield;
+
+ var errors = new GenericArray<Sparql.Error?> (n_updates);
+
+ if (task.error == null) {
+ for (i = 0; i < n_updates; i++)
+ errors.add (null);
+ } else {
+ // combined query was not successful, try queries one by one
+ for (i = 0; i < n_updates; i++) {
+ try {
+ yield update_async (sparql[i], priority, cancellable);
+ errors.add (null);
+ } catch (Sparql.Error e) {
+ errors.add (e);
+ }
+ }
+ }
+
+ return errors;
+ }
+
public override void load (File file, Cancellable? cancellable = null) throws Sparql.Error, IOError,
DBusError {
mutex.lock ();
try {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]