[tracker/rss-enclosures] Fixes NB#175723: Avoid duplicates if several monitor events arrive together and store is slow
- From: Roberto Guido <rguido src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/rss-enclosures] Fixes NB#175723: Avoid duplicates if several monitor events arrive together and store is slow
- Date: Sat, 26 Jun 2010 23:28:51 +0000 (UTC)
commit df3858cb203a0e36b4be9990ad59ad16c6af92aa
Author: Aleksander Morgado <aleksander lanedo com>
Date: Wed Jun 23 14:20:03 2010 +0200
Fixes NB#175723: Avoid duplicates if several monitor events arrive together and store is slow
* If a given file is being currently processed (in the processing_pool), a new event
on the same file must not be launched. Instead, the event is put back to the original
queue and QUEUE_WAIT returned.
src/libtracker-miner/tracker-miner-fs.c | 74 ++++++++++++++++++++++++------
1 files changed, 59 insertions(+), 15 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index 160a880..3e14b86 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -612,21 +612,31 @@ process_data_free (ProcessData *data)
static ProcessData *
process_data_find (TrackerMinerFS *fs,
- GFile *file)
+ GFile *file,
+ gboolean path_search)
{
GList *l;
for (l = fs->private->processing_pool; l; l = l->next) {
ProcessData *data = l->data;
- /* Different operations for the same file URI could be
- * piled up here, each being a different GFile object.
- * Miner implementations should really notify on the
- * same GFile object that's being passed, so we check for
- * pointer equality here, rather than doing path comparisons
- */
- if (data->file == file) {
- return data;
+ if (!path_search) {
+ /* Different operations for the same file URI could be
+ * piled up here, each being a different GFile object.
+ * Miner implementations should really notify on the
+ * same GFile object that's being passed, so we check for
+ * pointer equality here, rather than doing path comparisons
+ */
+ if(data->file == file)
+ return data;
+ } else {
+ /* Note that if there are different GFiles being
+ * processed for the same file path, we are actually
+ * returning the first one found, If you want exactly
+ * the same GFile as the one as input, use the
+ * process_data_find() method instead */
+ if (g_file_equal (data->file, file))
+ return data;
}
}
@@ -1317,7 +1327,7 @@ do_process_file (TrackerMinerFS *fs,
/* Re-fetch data, since it might have been
* removed in broken implementations
*/
- data = process_data_find (fs, data->file);
+ data = process_data_find (fs, data->file, FALSE);
g_message ("%s refused to process '%s'", G_OBJECT_TYPE_NAME (fs), uri);
@@ -1954,6 +1964,13 @@ item_queue_get_next_file (TrackerMinerFS *fs,
*file = NULL;
return QUEUE_IGNORE_NEXT_UPDATE;
}
+ if (process_data_find (fs, queue_file, TRUE)) {
+ *file = NULL;
+ /* Need to postpone event... */
+ g_queue_push_head (fs->private->items_deleted,
+ queue_file);
+ return QUEUE_WAIT;
+ }
*file = queue_file;
return QUEUE_DELETED;
}
@@ -1991,6 +2008,13 @@ item_queue_get_next_file (TrackerMinerFS *fs,
*source_file = queue_file;
return QUEUE_IGNORE_NEXT_UPDATE;
}
+ if (process_data_find (fs, queue_file, TRUE)) {
+ *file = NULL;
+ /* Need to postpone event... */
+ g_queue_push_head (fs->private->items_created,
+ queue_file);
+ return QUEUE_WAIT;
+ }
*file = queue_file;
*source_file = NULL;
return QUEUE_CREATED;
@@ -2003,17 +2027,37 @@ item_queue_get_next_file (TrackerMinerFS *fs,
*source_file = NULL;
if (check_ignore_next_update (fs, queue_file))
return QUEUE_IGNORE_NEXT_UPDATE;
+ if (process_data_find (fs, queue_file, TRUE)) {
+ *file = NULL;
+ /* Need to postpone event... */
+ g_queue_push_head (fs->private->items_updated,
+ queue_file);
+ return QUEUE_WAIT;
+ }
return QUEUE_UPDATED;
}
/* Moved items next */
data = g_queue_pop_head (fs->private->items_moved);
if (data) {
+ if (check_ignore_next_update (fs, data->file)) {
+ *file = g_object_ref (data->file);
+ *source_file = g_object_ref (data->source_file);
+ item_moved_data_free (data);
+ return QUEUE_IGNORE_NEXT_UPDATE;
+ }
+ if (process_data_find (fs, data->file, TRUE) ||
+ process_data_find (fs, data->source_file, TRUE)) {
+ *file = NULL;
+ *source_file = NULL;
+ /* Need to postpone event... */
+ g_queue_push_head (fs->private->items_moved,
+ data); /* no need to create again */
+ return QUEUE_WAIT;
+ }
*file = g_object_ref (data->file);
*source_file = g_object_ref (data->source_file);
item_moved_data_free (data);
- if (check_ignore_next_update (fs, *file))
- return QUEUE_IGNORE_NEXT_UPDATE;
return QUEUE_MOVED;
}
@@ -3375,7 +3419,7 @@ tracker_miner_fs_file_notify (TrackerMinerFS *fs,
fs->private->total_files_notified++;
- data = process_data_find (fs, file);
+ data = process_data_find (fs, file, FALSE);
if (!data) {
gchar *uri;
@@ -3477,7 +3521,7 @@ tracker_miner_fs_get_urn (TrackerMinerFS *fs,
g_return_val_if_fail (TRACKER_IS_MINER_FS (fs), NULL);
g_return_val_if_fail (G_IS_FILE (file), NULL);
- data = process_data_find (fs, file);
+ data = process_data_find (fs, file, FALSE);
if (!data) {
gchar *uri;
@@ -3518,7 +3562,7 @@ tracker_miner_fs_get_parent_urn (TrackerMinerFS *fs,
g_return_val_if_fail (TRACKER_IS_MINER_FS (fs), NULL);
g_return_val_if_fail (G_IS_FILE (file), NULL);
- data = process_data_find (fs, file);
+ data = process_data_find (fs, file, FALSE);
if (!data) {
gchar *uri;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]