beagle r4894 - trunk/beagle/beagled/FileSystemQueryable



Author: dbera
Date: Fri Dec 26 01:21:28 2008
New Revision: 4894
URL: http://svn.gnome.org/viewvc/beagle?rev=4894&view=rev

Log:
Fix a long standing bug.
While beagled is not running, if the EA of a file gets removed (e.g. due to some editors which do not copy the EA), then during next crawling beagle will add another document for the same file. As a result, the lucene index will have two documents for the same physical file. This will cause problems if the number of matches is more than the max-hits, fewer than max-hits matches will be returned (both the documents will match the query but both will resolve to the same physical file).
Ideally, while generating a new Id, one should check using the directory and the name if there is already an entry in the index for this file. This will slow down indexing during initial crawling but this is the right thing to do.


Modified:
   trunk/beagle/beagled/FileSystemQueryable/FileSystemQueryable.cs
   trunk/beagle/beagled/FileSystemQueryable/InternalUriManager.cs

Modified: trunk/beagle/beagled/FileSystemQueryable/FileSystemQueryable.cs
==============================================================================
--- trunk/beagle/beagled/FileSystemQueryable/FileSystemQueryable.cs	(original)
+++ trunk/beagle/beagled/FileSystemQueryable/FileSystemQueryable.cs	Fri Dec 26 01:21:28 2008
@@ -1093,7 +1093,7 @@
 			if (attr == null) {
 				if (Debug)
 					Logger.Log.Debug ("*** Index it: File has no attributes");
-				id = uid_manager.ReadOrCreateNewId (path);
+				id = uid_manager.ReadOrCreateNewId (dir, name);
 				return RequiredAction.Index;
 			}
 
@@ -1165,7 +1165,7 @@
 				if (path != last_known_path) {
 					if (Debug)
 						Logger.Log.Debug ("*** Name has also changed, assigning new unique id");
-					id = uid_manager.ReadOrCreateNewId (path);
+					id = uid_manager.CreateNewId (path);
 				}
 				
 				return RequiredAction.Index;

Modified: trunk/beagle/beagled/FileSystemQueryable/InternalUriManager.cs
==============================================================================
--- trunk/beagle/beagled/FileSystemQueryable/InternalUriManager.cs	(original)
+++ trunk/beagle/beagled/FileSystemQueryable/InternalUriManager.cs	Fri Dec 26 01:21:28 2008
@@ -338,7 +338,17 @@
 			cached_uid_by_path.Remove (path);
 		}
 
-		internal Guid ReadOrCreateNewId (string path)
+		internal Guid ReadOrCreateNewId (DirectoryModel dir, string name)
+		{
+			Guid old_guid = NameAndParentToId (name, dir);
+
+			if (old_guid != Guid.Empty)
+				return old_guid;
+
+			return CreateNewId (Path.Combine (dir.FullName, name));
+		}
+
+		internal Guid CreateNewId (string path)
 		{
 			if (cached_uid_by_path.Contains (path))
 				return (Guid) cached_uid_by_path [path];



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