beagle r4781 - in trunk/beagle: Filters beagled/IndexHelper



Author: dbera
Date: Fri Jun 13 11:24:49 2008
New Revision: 4781
URL: http://svn.gnome.org/viewvc/beagle?rev=4781&view=rev

Log:
* Fix our child URIs for the relevant filters. See UriFu comments for our URI format.
* The above fixes #535020.
* IndexHelper.cs: Fix running the helper by hand.


Modified:
   trunk/beagle/Filters/FilterArchive.cs
   trunk/beagle/Filters/FilterBibTex.cs
   trunk/beagle/Filters/FilterDocbook.cs
   trunk/beagle/Filters/FilterMail.cs
   trunk/beagle/Filters/FilterMonodoc.cs
   trunk/beagle/beagled/IndexHelper/IndexHelper.cs
   trunk/beagle/beagled/IndexHelper/RemoteIndexerExecutor.cs

Modified: trunk/beagle/Filters/FilterArchive.cs
==============================================================================
--- trunk/beagle/Filters/FilterArchive.cs	(original)
+++ trunk/beagle/Filters/FilterArchive.cs	Fri Jun 13 11:24:49 2008
@@ -171,15 +171,10 @@
 			++count;
 			total_size += a_entry.Size;
 
-			// FIXME: For nested archives, create uid:foo#bar
-			// instead of uid:foo#xxx#bar (avoid duplicates ?)
-			// FIXME: Construct correct Uri
-			// 1. Use Uri (foo, true): foo is not escaped. This creates serialization error for uris containing non-ascii character
-			// 2: Using Uri (foo): foo is escaped. This causes foo.zip#b#c (file c in archive b in archive foo) to be escaped to foo.zip#b%23c. This should be properly escaped back. Note that, file b#c in archive foo.zip would also be escaped to foo.zip#b%23c. If there is any problem about incorrect filename containing '#' in an archive, then System.Uri should be abandoned and a custom Beagle.Uri should be created which can handle multiple fragments.
-			// If you read the Uri related FIXMEs and hacks in beagled/*Queryable,
-			// then you would see why creating Beagle.Uri class over System.Uri
-			// is not at all a bad idea :)
-			child = new Indexable (new Uri (Indexable.Uri.ToString () + "#" + a_entry.Name));
+			// Add "#<escaped-path-to-entry>" to the end of the Indexable Uri
+			// So, file b#c in archive foo.zip becomes file:///foo.zip#b%23c
+			// And file c in archive b in archive foo.zip becomes file:///foo.zip#b#c
+			child = new Indexable (UriFu.AddFragment (Indexable.Uri, a_entry.Name, false));
 
 			child.CacheContent = true;
 			child.MimeType = a_entry.MimeType;

Modified: trunk/beagle/Filters/FilterBibTex.cs
==============================================================================
--- trunk/beagle/Filters/FilterBibTex.cs	(original)
+++ trunk/beagle/Filters/FilterBibTex.cs	Fri Jun 13 11:24:49 2008
@@ -125,10 +125,10 @@
 			if (line == null)
 				return false;
 
-			child = new Indexable (new Uri (Indexable.Uri.ToString() + "#" + name));
+			child = new Indexable (UriFu.AddFragment (Indexable.Uri, name, false));
 			child.CacheContent = false;
 			child.MimeType = "text/x-bibtex";
-			child.DisplayUri = (new Uri (Indexable.Uri.ToString() + "#" + name));
+			child.DisplayUri = child.Uri;
 			child.NoContent = true;
 			child.AddProperty (Property.NewKeyword ("bibtex:type", type));
 

Modified: trunk/beagle/Filters/FilterDocbook.cs
==============================================================================
--- trunk/beagle/Filters/FilterDocbook.cs	(original)
+++ trunk/beagle/Filters/FilterDocbook.cs	Fri Jun 13 11:24:49 2008
@@ -58,7 +58,7 @@
 		public FilterDocbook ()
 		{
 			SnippetMode = false;
-			SetVersion (4);
+			SetVersion (5);
 			SetFileType ("documentation");
 		}
 
@@ -159,7 +159,8 @@
 						if (entries_stack.Count > 0)
 							parent_entry = (DocbookEntry) entries_stack.Peek ();
 						
-						Indexable indexable = new Indexable (UriFu.PathToFileUri (String.Format ("{0}#{1}", base_path, entry.Id)));
+						Indexable indexable;
+						indexable = new Indexable (UriFu.AddFragment (Indexable.Uri, entry.Id, false));
 						indexable.HitType = "DocbookEntry";
 						indexable.MimeType = "text/x-docbook-entry";
 						indexable.Filtering = IndexableFiltering.AlreadyFiltered;

Modified: trunk/beagle/Filters/FilterMail.cs
==============================================================================
--- trunk/beagle/Filters/FilterMail.cs	(original)
+++ trunk/beagle/Filters/FilterMail.cs	Fri Jun 13 11:24:49 2008
@@ -442,8 +442,9 @@
 						// attachments along with (real) attachments.
 
 						if (Array.IndexOf (blacklisted_mime_types, mime_type) == -1) {
-							string sub_uri = this.indexable.Uri.ToString () + "#" + this.count;
-							Indexable child = new Indexable (new Uri (sub_uri));
+							string sub_uri = "#" + this.count;
+							Indexable child;
+							child = new Indexable (UriFu.AddFragment (this.indexable.Uri, sub_uri, true));
 
 							child.DisplayUri = new Uri (this.indexable.DisplayUri.ToString () + "#" + this.count);
 

Modified: trunk/beagle/Filters/FilterMonodoc.cs
==============================================================================
--- trunk/beagle/Filters/FilterMonodoc.cs	(original)
+++ trunk/beagle/Filters/FilterMonodoc.cs	Fri Jun 13 11:24:49 2008
@@ -100,7 +100,7 @@
 				if (type == null)
 					continue;
 				
-				Indexable type_indexable = TypeNodeToIndexable (type, FileInfo);
+				Indexable type_indexable = TypeNodeToIndexable (type, Indexable.Uri);
 				type_indexable.SetChildOf (this.Indexable);
 				type_indexable.StoreStream ();
 				type_indexable.CloseStreams ();
@@ -108,7 +108,7 @@
 				
 				foreach(XmlNode member in type.SelectNodes ("Members/Member")) {
 					Indexable member_indexable = MemberNodeToIndexable (member,
-											    FileInfo,
+											    Indexable.Uri,
 											    type.Attributes ["FullName"].Value);
 					member_indexable.SetChildOf (this.Indexable);
 					member_indexable.StoreStream ();
@@ -120,9 +120,10 @@
 			Finished ();
 		}
 
-		static private Indexable TypeNodeToIndexable (XmlNode node, FileInfo file)
+		static private Indexable TypeNodeToIndexable (XmlNode node, Uri base_uri)
 		{
-			Indexable indexable = new Indexable (UriFu.PathToFileUri (file + "#T:" + node.Attributes ["FullName"].Value));
+			string fragment = "T:" + node.Attributes ["FullName"].Value;
+			Indexable indexable = new Indexable (UriFu.AddFragment (base_uri, fragment, false));
 			
 			indexable.MimeType = "text/html";
 			indexable.HitType = "MonodocEntry";
@@ -137,7 +138,7 @@
 			return indexable;
 		}
 		
-		static private Indexable MemberNodeToIndexable(XmlNode node, FileInfo file, string parentName)
+		static private Indexable MemberNodeToIndexable(XmlNode node, Uri base_uri, string parentName)
 		{
 			char memberType = MemberTypeToChar (node.SelectSingleNode ("MemberType").InnerText);
 			StringBuilder memberFullName = new StringBuilder ();
@@ -159,7 +160,7 @@
 				memberFullName.Append (")");
 			}
 
-			Indexable indexable = new Indexable (UriFu.PathToFileUri (file + "#" + memberFullName));
+			Indexable indexable = new Indexable (UriFu.AddFragment (base_uri, memberFullName.ToString (), false));
 
 			indexable.MimeType = "text/html";
 			indexable.HitType = "MonodocEntry";

Modified: trunk/beagle/beagled/IndexHelper/IndexHelper.cs
==============================================================================
--- trunk/beagle/beagled/IndexHelper/IndexHelper.cs	(original)
+++ trunk/beagle/beagled/IndexHelper/IndexHelper.cs	Fri Jun 13 11:24:49 2008
@@ -163,12 +163,14 @@
 				// Whether we should generate heap-shot snapshots
 				heap_shot = (Environment.GetEnvironmentVariable ("_HEY_LETS_DO_A_HEAP_SHOT") != null);
 
-				// Start the monitor thread, which keeps an eye on memory usage and idle time.
-				ExceptionHandlingThread.Start (new ThreadStart (MemoryAndIdleMonitorWorker));
-
-				// Start a thread that watches the daemon and begins a shutdown
-				// if it terminates.
-				ExceptionHandlingThread.Start (new ThreadStart (DaemonMonitorWorker));
+				if (! run_by_hand) {
+					// Start the monitor thread, which keeps an eye on memory usage and idle time.
+					ExceptionHandlingThread.Start (new ThreadStart (MemoryAndIdleMonitorWorker));
+
+					// Start a thread that watches the daemon and begins a shutdown
+					// if it terminates.
+					ExceptionHandlingThread.Start (new ThreadStart (DaemonMonitorWorker));
+				}
 
 				// Start the main loop
 				main_loop.Run ();

Modified: trunk/beagle/beagled/IndexHelper/RemoteIndexerExecutor.cs
==============================================================================
--- trunk/beagle/beagled/IndexHelper/RemoteIndexerExecutor.cs	(original)
+++ trunk/beagle/beagled/IndexHelper/RemoteIndexerExecutor.cs	Fri Jun 13 11:24:49 2008
@@ -43,8 +43,6 @@
 		static public int Count = 0;
 		static Hashtable indexer_table = new Hashtable ();
 
-		Indexable[] child_indexables;
-
 		public override ResponseMessage Execute (RequestMessage raw_request)
 		{
 			RemoteIndexerRequest remote_request = (RemoteIndexerRequest) raw_request;



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