[tracker/rss-enclosures] libtracker-miner: If parent being processed, wait.



commit ce7fea428fba7f274af8dde051a2042596035b14
Author: Aleksander Morgado <aleksander lanedo com>
Date:   Thu Aug 5 20:34:30 2010 +0200

    libtracker-miner: If parent being processed, wait.

 src/libtracker-miner/tracker-miner-fs.c |   47 +++++++++++++++++++++++++++---
 1 files changed, 42 insertions(+), 5 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index ea4bc1e..12d9116 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -2041,6 +2041,35 @@ fill_in_queue (TrackerMinerFS       *fs,
 	}
 }
 
+
+static gboolean
+should_wait (TrackerMinerFS *fs,
+             GFile          *file)
+{
+	GFile *parent;
+
+	/* Is the item already being processed? */
+	if (process_data_find (fs, file, TRUE)) {
+		/* Yes, a previous event on same item currently
+		 * being processed */
+		return TRUE;
+	}
+
+	/* Is the item's parent being processed right now? */
+	parent = g_file_get_parent (file);
+	if (parent) {
+		if (process_data_find (fs, parent, TRUE)) {
+			/* Yes, a previous event on the parent of this item
+			 * currently being processed */
+			g_object_unref (parent);
+			return TRUE;
+		}
+
+		g_object_unref (parent);
+	}
+	return FALSE;
+}
+
 static QueueState
 item_queue_get_next_file (TrackerMinerFS  *fs,
                           GFile          **file,
@@ -2059,7 +2088,9 @@ item_queue_get_next_file (TrackerMinerFS  *fs,
 			return QUEUE_IGNORE_NEXT_UPDATE;
 		}
 
-		if (process_data_find (fs, queue_file, TRUE)) {
+		/* If the same item OR its first parent is currently being processed,
+		 * we need to wait for this event */
+		if (should_wait (fs, queue_file)) {
 			*file = NULL;
 			/* Need to postpone event... */
 			g_queue_push_head (fs->private->items_deleted,
@@ -2105,7 +2136,9 @@ item_queue_get_next_file (TrackerMinerFS  *fs,
 			return QUEUE_IGNORE_NEXT_UPDATE;
 		}
 
-		if (process_data_find (fs, queue_file, TRUE)) {
+		/* If the same item OR its first parent is currently being processed,
+		 * we need to wait for this event */
+		if (should_wait (fs, queue_file)) {
 			*file = NULL;
 			/* Need to postpone event... */
 			g_queue_push_head (fs->private->items_created,
@@ -2127,7 +2160,9 @@ item_queue_get_next_file (TrackerMinerFS  *fs,
 		if (check_ignore_next_update (fs, queue_file))
 			return QUEUE_IGNORE_NEXT_UPDATE;
 
-		if (process_data_find (fs, queue_file, TRUE)) {
+		/* If the same item OR its first parent is currently being processed,
+		 * we need to wait for this event */
+		if (should_wait (fs, queue_file)) {
 			*file = NULL;
 			/* Need to postpone event... */
 			g_queue_push_head (fs->private->items_updated,
@@ -2148,8 +2183,10 @@ item_queue_get_next_file (TrackerMinerFS  *fs,
 			return QUEUE_IGNORE_NEXT_UPDATE;
 		}
 
-		if (process_data_find (fs, data->file, TRUE) ||
-		    process_data_find (fs, data->source_file, TRUE)) {
+		/* If the same item OR its first parent is currently being processed,
+		 * we need to wait for this event */
+		if (should_wait (fs, data->file) ||
+		    should_wait (fs, data->source_file)) {
 			*file = NULL;
 			*source_file = NULL;
 			/* Need to postpone event... */



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