nemo r94 - trunk/metadata



Author: arj
Date: Mon Mar 10 16:33:29 2008
New Revision: 94
URL: http://svn.gnome.org/viewvc/nemo?rev=94&view=rev

Log:
Fix #520790: On reindex delete files that is now gone from the file system

Thanks to Brev Towe for finding this.



Modified:
   trunk/metadata/MetadataStore.cs

Modified: trunk/metadata/MetadataStore.cs
==============================================================================
--- trunk/metadata/MetadataStore.cs	(original)
+++ trunk/metadata/MetadataStore.cs	Mon Mar 10 16:33:29 2008
@@ -159,7 +159,10 @@
         string[] exclude_dirs;
         string[] excludes;
         string[] includes;
-        
+
+		// for reindexing
+		List<string> indexed_filenames;
+		
         // main thread methods
         public MetadataStore(string watch_path)
         {
@@ -170,6 +173,8 @@
             excludes = Singleton<Configuration>.Instance.data.exclude_files.Split(' ');
             includes = Singleton<Configuration>.Instance.data.include_files.Split(' ');
             exclude_dirs = Singleton<Configuration>.Instance.data.exclude_dirs.Split(' ');
+			
+			indexed_filenames = new List<string>();
         }
 
 		// workaround braindead filter interface on FileSystemWatcher
@@ -825,7 +830,17 @@
 
 			int nr_changes = 0;
 			
-           	// performance
+			foreach (string filename in add_files)
+			{
+				indexed_filenames.Add(filename);			
+			}
+			
+			foreach (string filename in update_files)
+			{
+				indexed_filenames.Add(filename);			
+			}
+
+			// performance
 			if (inserted)
 				database.start_transaction();
 
@@ -866,7 +881,8 @@
 				db_handle_change(file);
 			}
 
-			dir_sync_count -= 1;
+			if (dir_sync_count > 0)
+				dir_sync_count -= 1;
 
 			if (inserted)
 				database.end_transaction();
@@ -906,6 +922,10 @@
 			
 			// finished indexing
 			if (dir_sync_count == 0) {
+
+				database.clean_database_of_nonexisting_files(indexed_filenames);
+				indexed_filenames.Clear();
+				
 				Helpers.RunInMainThread(delegate {
 					Singleton<Indexing>.Instance.change_status(false);
 				})();
@@ -1756,5 +1776,13 @@
                 return files;
             }
 		}
+
+		public void clean_database_of_nonexisting_files(List<string> paths)
+		{
+            using (IDbCommand cmd = get_command()) {
+				cmd.CommandText = "delete from files where path not in ('" + String.Join("', '", paths.ToArray()) + "')";
+                cmd.ExecuteNonQuery();
+            }
+		}
 	}
 }
\ No newline at end of file



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