[tracker/writeback-refactor-rebase: 21/28] miners/fs, libtracker-miner: Retry writeback on unmount event



commit 42a85a7113a26fc760a1869a54362e6573834fcb
Author: Philip Van Hoof <philip codeminded be>
Date:   Mon Jul 18 12:23:32 2011 +0200

    miners/fs, libtracker-miner: Retry writeback on unmount event

 src/libtracker-miner/tracker-miner-fs.c      |   32 +++++++++++++++++++++-----
 src/libtracker-miner/tracker-miner-fs.h      |    2 +
 src/miners/fs/tracker-writeback-dispatcher.c |   11 ++++++++-
 3 files changed, 38 insertions(+), 7 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index 98934b5..f99b24c 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -4718,14 +4718,13 @@ tracker_miner_fs_writeback_file (TrackerMinerFS *fs,
 
 	path = g_file_get_path (file);
 
-	g_debug ("%s (WRITEBACK) (requested by application)",
-	         path);
+	g_debug ("%s (WRITEBACK) (requested by application)", path);
 
 	trace_eq_push_tail ("WRITEBACK", file, "Requested by application");
 
 	data = item_writeback_data_new (file, rdf_types, results);
-	g_queue_push_tail (fs->priv->items_writeback,
-	                   data);
+	tracker_priority_queue_add (fs->priv->items_writeback, data,
+				    G_PRIORITY_DEFAULT);
 
 	item_queue_handlers_set_up (fs);
 
@@ -4736,6 +4735,8 @@ tracker_miner_fs_writeback_file (TrackerMinerFS *fs,
  * tracker_miner_fs_writeback_notify:
  * @fs: a #TrackerMinerFS
  * @file: a #GFile
+ * @rdf_types: a #GStrv
+ * @resutls: a #GPtrArray
  * @error: a #GError with the error that happened during processing, or %NULL.
  *
  * Notifies @fs that all writing back on @file has been finished, if any error
@@ -4747,11 +4748,30 @@ tracker_miner_fs_writeback_file (TrackerMinerFS *fs,
 void
 tracker_miner_fs_writeback_notify (TrackerMinerFS *fs,
                                    GFile          *file,
+                                   GStrv           rdf_types,
+                                   GPtrArray      *results,
                                    const GError   *error)
 {
-#warning todo here
+	if (error && error->code == G_DBUS_ERROR_NO_REPLY) {
+		ItemWritebackData *data;
+		gchar *path;
+
+		/* This happens in case of exit() of the tracker-writeback binary, which
+		 * happens on unmount of the FS event, for example */
+
+		path = g_file_get_path (file);
+
+		g_debug ("%s (WRITEBACK) (retry after unmount event)", path);
+		trace_eq_push_tail ("WRITEBACK", file, "Retry after unmount event");
+
+		data = item_writeback_data_new (file, rdf_types, results);
 
-	/* TODO */
+		g_queue_push_tail (fs->priv->items_writeback, data);
+
+		item_queue_handlers_set_up (fs);
+
+		g_free (path);
+	}
 }
 
 /**
diff --git a/src/libtracker-miner/tracker-miner-fs.h b/src/libtracker-miner/tracker-miner-fs.h
index cd4a493..d487f35 100644
--- a/src/libtracker-miner/tracker-miner-fs.h
+++ b/src/libtracker-miner/tracker-miner-fs.h
@@ -136,6 +136,8 @@ void                  tracker_miner_fs_writeback_file       (TrackerMinerFS *fs,
                                                              GPtrArray      *results);
 void                  tracker_miner_fs_writeback_notify     (TrackerMinerFS *fs,
                                                              GFile          *file,
+                                                             GStrv           rdf_types,
+                                                             GPtrArray      *results,
                                                              const GError   *error);
 void                  tracker_miner_fs_check_directory      (TrackerMinerFS *fs,
                                                              GFile          *file,
diff --git a/src/miners/fs/tracker-writeback-dispatcher.c b/src/miners/fs/tracker-writeback-dispatcher.c
index 21d721b..4e2dafe 100644
--- a/src/miners/fs/tracker-writeback-dispatcher.c
+++ b/src/miners/fs/tracker-writeback-dispatcher.c
@@ -32,6 +32,8 @@
 typedef struct {
 	GFile *file;
 	TrackerMinerFS *fs;
+	GPtrArray *results;
+	GStrv rdf_types;
 } WritebackFileData;
 
 typedef struct {
@@ -233,10 +235,15 @@ writeback_file_finished  (GObject      *source_object,
 	g_dbus_connection_call_finish (G_DBUS_CONNECTION (source_object),
 	                               res, &error);
 
-	tracker_miner_fs_writeback_notify (data->fs, data->file, error);
+	tracker_miner_fs_writeback_notify (data->fs, data->file,
+	                                   data->rdf_types,
+	                                   data->results,
+	                                   error);
 
 	g_object_unref (data->fs);
 	g_object_unref (data->file);
+	g_strfreev (data->rdf_types);
+	g_ptr_array_unref (data->results);
 	g_free (data);
 }
 
@@ -287,6 +294,8 @@ writeback_dispatcher_writeback_file (TrackerMinerFS *fs,
 
 	data->fs = g_object_ref (fs);
 	data->file = g_object_ref (file);
+	data->results = g_ptr_array_ref (results);
+	data->rdf_types = g_strdupv (rdf_types);
 
 	g_dbus_connection_call (priv->d_connection,
 	                        TRACKER_WRITEBACK_SERVICE,



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