diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2017-10-16 11:46:38 +0200 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2017-11-14 22:45:26 +0100 |
commit | 5eede395c234555d1892275ba2959ac0b0d851ef (patch) | |
tree | 55147e1d69ab751e16d7f4e4795fd103235d42e8 | |
parent | 4ae25396edaadc706fd7d02c4628e746a537476d (diff) | |
download | tracker-5eede395c234555d1892275ba2959ac0b0d851ef.tar.gz |
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.
-rw-r--r-- | 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 06c6523b5..6c841a292 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 { |