[tracker] TrackerMinerFS: Do recursive index on move ops where whe source isn't known.



commit f7b43923dc4a360c1418d7dcebfda93cfeff1ed0
Author: Carlos Garnacho <carlos lanedo com>
Date:   Thu Mar 11 16:57:39 2010 +0100

    TrackerMinerFS: Do recursive index on move ops where whe source isn't known.
    
    If a directory being moved didn't have the source indexed, TrackerMinerFS
    will recursively index it.

 src/libtracker-miner/tracker-miner-fs.c |   50 +++++++++++++++++++++---------
 1 files changed, 35 insertions(+), 15 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index b36ba62..b14bc20 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -1468,37 +1468,53 @@ item_move (TrackerMinerFS *fs,
 	RecursiveMoveData move_data;
 	ProcessData *data;
 	gchar *source_iri;
+	gboolean source_exists;
 
 	uri = g_file_get_uri (file);
 	source_uri = g_file_get_uri (source_file);
 
+	file_info = g_file_query_info (file,
+	                               G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME ","
+	                               G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE ","
+				       G_FILE_ATTRIBUTE_STANDARD_TYPE,
+	                               G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
+	                               NULL, NULL);
+
 	/* Get 'source' ID */
-	if (!item_query_exists (fs, source_file, &source_iri, NULL)) {
-		gboolean retval;
+	source_exists = item_query_exists (fs, source_file, &source_iri, NULL);
 
-		g_message ("Source file '%s' not found in store to move, indexing '%s' from scratch", source_uri, uri);
+	if (!file_info) {
+		gboolean retval;
 
-		retval = item_add_or_update (fs, file);
+		if (source_exists) {
+			/* Destination file has gone away, ignore dest file and remove source if any */
+			retval = item_remove (fs, source_file);
+		} else {
+			/* Destination file went away, and source wasn't indexed either */
+			retval = TRUE;
+		}
 
+		g_free (source_iri);
 		g_free (source_uri);
 		g_free (uri);
 
 		return retval;
-	}
+	} else if (file_info && !source_exists) {
+		gboolean retval;
+		GFileType file_type;
 
-	file_info = g_file_query_info (file,
-	                               G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME ","
-	                               G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
-	                               G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
-	                               NULL, NULL);
+		g_message ("Source file '%s' not found in store to move, indexing '%s' from scratch", source_uri, uri);
 
-	if (!file_info) {
-		gboolean retval;
+		file_type = g_file_info_get_file_type (file_info);
 
-		/* Destination file has gone away, ignore dest file and remove source if any */
-		retval = item_remove (fs, source_file);
+		if (file_type == G_FILE_TYPE_DIRECTORY) {
+			/* We're dealing with a directory, index recursively */
+			tracker_miner_fs_directory_add (fs, file, TRUE);
+			retval = TRUE;
+		} else {
+			retval = item_add_or_update (fs, file);
+		}
 
-		g_free (source_iri);
 		g_free (source_uri);
 		g_free (uri);
 
@@ -2507,6 +2523,10 @@ crawl_directories_cb (gpointer user_data)
 		return FALSE;
 	}
 
+	if (!fs->private->timer) {
+		fs->private->timer = g_timer_new ();
+	}
+
 	fs->private->current_directory = fs->private->directories->data;
 	fs->private->directories = g_list_remove (fs->private->directories,
 	                                          fs->private->current_directory);



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