beagle r4611 - trunk/beagle/bludgeon



Author: dbera
Date: Tue Mar 18 01:11:52 2008
New Revision: 4611
URL: http://svn.gnome.org/viewvc/beagle?rev=4611&view=rev

Log:
Give bludgeon long-overdue love.
* Fix parameters passed to beagled
* Use our crazy Uri and Uri escape methods instead of dealing with Uris
itself.
* Passes non-archive tests. Archives do not pass the test yet, due to
some more Uri weirdness.


Modified:
   trunk/beagle/bludgeon/Bludgeon.cs
   trunk/beagle/bludgeon/Bzip2FileObject.cs
   trunk/beagle/bludgeon/Daemon.cs
   trunk/beagle/bludgeon/DirectoryObject.cs
   trunk/beagle/bludgeon/FileSystemObject.cs
   trunk/beagle/bludgeon/GzipFileObject.cs
   trunk/beagle/bludgeon/SanityCheck.cs
   trunk/beagle/bludgeon/TarFileObject.cs
   trunk/beagle/bludgeon/TextFileObject.cs
   trunk/beagle/bludgeon/ZipFileObject.cs

Modified: trunk/beagle/bludgeon/Bludgeon.cs
==============================================================================
--- trunk/beagle/bludgeon/Bludgeon.cs	(original)
+++ trunk/beagle/bludgeon/Bludgeon.cs	Tue Mar 18 01:11:52 2008
@@ -159,10 +159,10 @@
 
 			root = CreateTestRoot ();
 			TreeBuilder.Build (root,
-					   30,    // three directories
-					   100,   // ten files
-					   0.1,   // no archives
-					   0.5,   // archive decay, which does nothing here
+					   30,    // number of directories
+					   100,   // number of files
+					   0, //0.1,   // no archives
+					   0, //0.5,   // archive decay, which does nothing here
 					   false, // build all directories first, not in random order
 					   null); // no need to track events
 			if (! root.VerifyOnDisk ())

Modified: trunk/beagle/bludgeon/Bzip2FileObject.cs
==============================================================================
--- trunk/beagle/bludgeon/Bzip2FileObject.cs	(original)
+++ trunk/beagle/bludgeon/Bzip2FileObject.cs	Tue Mar 18 01:11:52 2008
@@ -20,10 +20,10 @@
 			AddChild (bzip2ed_file, null);
 		}
 
-		override protected string GetChildUri (FileSystemObject children)
+		override protected Uri GetChildUri (FileSystemObject children)
 		{
 			// FIXME: What is the uri scheme for bzip2 files?
-			return this.Uri + "#" + children.Name;
+			return new Uri (this.Uri.ToString () + "#" + children.Name);
 		}
 
 		override public string MimeType {
@@ -40,7 +40,7 @@
 				throw new Exception ("Bzip2 file " + Uri + " has " + ChildCount + " children");
 
 			if (tracker != null)
-				tracker.ExpectingAdded (this.Uri);
+				tracker.ExpectingAdded (UriFu.UriToEscapedString (this.Uri));
 
 			UnclosableStream unclosable;
 			unclosable = new UnclosableStream (stream);

Modified: trunk/beagle/bludgeon/Daemon.cs
==============================================================================
--- trunk/beagle/bludgeon/Daemon.cs	(original)
+++ trunk/beagle/bludgeon/Daemon.cs	Tue Mar 18 01:11:52 2008
@@ -128,7 +128,7 @@
 			beagled = Environment.GetEnvironmentVariable ("BEAGLED_COMMAND");
 
 			string args;
-			args = "--debug-memory --bg --allow-backend files";
+			args = "--debug-memory --bg --backend Files";
 
 			if (UseHeapBuddy)
 				args += " --heap-buddy";

Modified: trunk/beagle/bludgeon/DirectoryObject.cs
==============================================================================
--- trunk/beagle/bludgeon/DirectoryObject.cs	(original)
+++ trunk/beagle/bludgeon/DirectoryObject.cs	Tue Mar 18 01:11:52 2008
@@ -47,15 +47,17 @@
 			}
 		}
 
-		override protected string GetChildUri (FileSystemObject child)
+		override protected Uri GetChildUri (FileSystemObject child)
 		{
-			return Path.Combine (this.Uri, child.Name);
+			string s = Path.Combine (UriFu.UriToEscapedString (this.Uri), child.Name);
+			//Console.WriteLine ("Asked to combine {0} and {1} = {2}", UriFu.UriToEscapedString (this.Uri), child.Name, s);
+			return UriFu.EscapedStringToUri (s);
 		}
 
-		override public string Uri {
+		override public Uri Uri {
 			get {
 				if (is_root)
-					return "file://" + root_path;
+					return UriFu.PathToFileUri (root_path);
 				return base.Uri;
 			}
 		}
@@ -164,7 +166,7 @@
 			}
 
 			if (tracker != null)
-				tracker.ExpectingAdded (this.Uri);
+				tracker.ExpectingAdded (UriFu.UriToEscapedString (this.Uri));
 
 			// Recursively add the children
 			foreach (FileSystemObject fso in children.Values)

Modified: trunk/beagle/bludgeon/FileSystemObject.cs
==============================================================================
--- trunk/beagle/bludgeon/FileSystemObject.cs	(original)
+++ trunk/beagle/bludgeon/FileSystemObject.cs	Tue Mar 18 01:11:52 2008
@@ -18,8 +18,7 @@
 
 	abstract public class FileSystemObject {
 
-		// TURN THIS ON TO TEST THE ARCHIVE PATCH!
-		static public bool SearchInArchives = false;
+		const bool SearchInArchives = true;
 
 		private static int next_id = 0;
 
@@ -184,15 +183,15 @@
 			get { return null; }
 		}
 
-		virtual protected string GetChildUri (FileSystemObject child)
+		virtual protected Uri GetChildUri (FileSystemObject child)
 		{
 			throw new Exception ("Invalid GetChildUri call");
 		}
 
-		virtual public string Uri {
+		virtual public Uri Uri {
 			get {
 				if (parent == null)
-					return "floating://" + Name;
+					return new Uri ("floating://" + Name);
 				return parent.GetChildUri (this);
 			}
 		}
@@ -229,7 +228,7 @@
 		public ICollection Children {
 			get {
 				if (children == null)
-					throw new Exception ("Invalid request for children on " + Uri);
+					throw new Exception ("Invalid request for children on " + Uri.ToString ());
 				return children.Values;
 			}
 		}
@@ -237,16 +236,16 @@
 		public FileSystemObject GetChild (string name)
 		{
 			if (children == null)
-				throw new Exception ("Invalid request for child '" + name + "' on " + Uri);
+				throw new Exception ("Invalid request for child '" + name + "' on " + Uri.ToString ());
 			return children [name] as FileSystemObject;
 		}
 
 		public virtual void AddChild (FileSystemObject child, EventTracker tracker)
 		{
 			if (children == null)
-				throw new Exception ("Can't add a child to " + Uri);
+				throw new Exception ("Can't add a child to " + Uri.ToString ());
 			if (child.parent != null)
-				throw new Exception ("Can't add parented child " + child.Uri + " to " + Uri);
+				throw new Exception ("Can't add parented child " + child.Uri.ToString () + " to " + Uri.ToString ());
 
 			// FIXME: Need to handle the case of the added child
 			// clobbering another w/ the same name.
@@ -261,11 +260,11 @@
 		public virtual void ClobberingAddChild (FileSystemObject child, FileSystemObject victim, EventTracker tracker)
 		{
 			if (children == null)
-				throw new Exception ("Can't add a child to " + Uri);
+				throw new Exception ("Can't add a child to " + Uri.ToString ());
 			if (child.parent != null)
-				throw new Exception ("Can't add parented child " + child.Uri + " to " + Uri);
+				throw new Exception ("Can't add parented child " + child.Uri.ToString () + " to " + Uri.ToString ());
 			if (victim.parent != this)
-				throw new Exception ("Victim " + victim.Uri + " is not a child of " + Uri);
+				throw new Exception ("Victim " + victim.Uri.ToString () + " is not a child of " + Uri.ToString ());
 			if (child.Extension != victim.Extension)
 				throw new Exception ("Extension mismatch: " + child.Extension + " vs. " + victim.Extension);
 
@@ -283,7 +282,7 @@
 		public virtual void RemoveChild (FileSystemObject child, EventTracker tracker)
 		{
 			if (child.parent != this)
-				throw new Exception (child.Uri + " is not a child of " + Uri);
+				throw new Exception (child.Uri.ToString () + " is not a child of " + Uri.ToString ());
 
 			if (IsRooted)
 				child.DeleteOnDisk (tracker);
@@ -295,7 +294,7 @@
 		public virtual void MoveChild (FileSystemObject child, FileSystemObject new_parent, EventTracker tracker)
 		{
 			if (child.parent != this)
-				throw new Exception (child.Uri + " is not a child of " + Uri);
+				throw new Exception (child.Uri.ToString () + " is not a child of " + Uri.ToString ());
 
 			if (new_parent == null || new_parent == child.parent)
 				return;
@@ -303,7 +302,7 @@
 			// We can't move child into new_parent if child is
 			// already above new_parent in the tree.
 			if (child.IsAncestorOf (new_parent))
-				throw new Exception ("Can't move " + child.Uri + " to " + new_parent.Uri);
+				throw new Exception ("Can't move " + child.Uri.ToString () + " to " + new_parent.Uri.ToString ());
 			
 			string old_full_name;
 			old_full_name = child.FullName;

Modified: trunk/beagle/bludgeon/GzipFileObject.cs
==============================================================================
--- trunk/beagle/bludgeon/GzipFileObject.cs	(original)
+++ trunk/beagle/bludgeon/GzipFileObject.cs	Tue Mar 18 01:11:52 2008
@@ -20,10 +20,10 @@
 			AddChild (gzipped_file, null);
 		}
 
-		override protected string GetChildUri (FileSystemObject children)
+		override protected Uri GetChildUri (FileSystemObject children)
 		{
 			// FIXME: What is the uri scheme for gzip files?
-			return this.Uri + "#" + children.Name;
+			return new Uri (this.Uri.ToString () + "#" + children.Name);
 		}
 
 		override public string MimeType {
@@ -40,7 +40,7 @@
 				throw new Exception ("Gzip file " + Uri + " has " + ChildCount + " children");
 
 			if (tracker != null)
-				tracker.ExpectingAdded (this.Uri);
+				tracker.ExpectingAdded (UriFu.UriToEscapedString (this.Uri));
 
 			UnclosableStream unclosable;
 			unclosable = new UnclosableStream (stream);

Modified: trunk/beagle/bludgeon/SanityCheck.cs
==============================================================================
--- trunk/beagle/bludgeon/SanityCheck.cs	(original)
+++ trunk/beagle/bludgeon/SanityCheck.cs	Tue Mar 18 01:11:52 2008
@@ -29,10 +29,11 @@
 			success = true;
 
 			foreach (FileSystemObject fso in matching_fsos) {
-				if (matching_hits.Contains (fso.Uri))
-					matching_hits.Remove (fso.Uri);
+				string uri = UriFu.UriToEscapedString (fso.Uri);
+				if (matching_hits.Contains (uri))
+					matching_hits.Remove (uri);
 				else {
-					Log.Failure ("Hit missing from beagled query results: {0}", fso.Uri);
+					Log.Failure ("Hit missing from beagled query results: {0}", uri);
 					success = false;
 				}
 			}

Modified: trunk/beagle/bludgeon/TarFileObject.cs
==============================================================================
--- trunk/beagle/bludgeon/TarFileObject.cs	(original)
+++ trunk/beagle/bludgeon/TarFileObject.cs	Tue Mar 18 01:11:52 2008
@@ -31,10 +31,10 @@
 			}
 		}
 
-		override protected string GetChildUri (FileSystemObject children)
+		override protected Uri GetChildUri (FileSystemObject children)
 		{
 			// FIXME: What is the uri scheme for tar files?
-			return this.Uri + "#" + children.Name;
+			return new Uri (this.Uri.ToString () + "#" + children.Name);
 		}
 
 		override public string MimeType {
@@ -91,7 +91,7 @@
 		override public void AddToStream (Stream stream, EventTracker tracker)
 		{
 			if (tracker != null)
-				tracker.ExpectingAdded (this.Uri);
+				tracker.ExpectingAdded (UriFu.UriToEscapedString (this.Uri));
 
 			UnclosableStream unclosable;
 			unclosable = new UnclosableStream (stream);

Modified: trunk/beagle/bludgeon/TextFileObject.cs
==============================================================================
--- trunk/beagle/bludgeon/TextFileObject.cs	(original)
+++ trunk/beagle/bludgeon/TextFileObject.cs	Tue Mar 18 01:11:52 2008
@@ -32,7 +32,7 @@
 		override public void AddToStream (Stream stream, EventTracker tracker)
 		{
 			if (tracker != null)
-				tracker.ExpectingAdded (this.Uri);
+				tracker.ExpectingAdded (UriFu.UriToEscapedString (this.Uri));
 			
 			// We can't just use a StreamWriter here, since that
 			// will close the underlying stream when it gets

Modified: trunk/beagle/bludgeon/ZipFileObject.cs
==============================================================================
--- trunk/beagle/bludgeon/ZipFileObject.cs	(original)
+++ trunk/beagle/bludgeon/ZipFileObject.cs	Tue Mar 18 01:11:52 2008
@@ -26,10 +26,10 @@
 			}
 		}
 
-		override protected string GetChildUri (FileSystemObject children)
+		override protected Uri GetChildUri (FileSystemObject children)
 		{
 			// FIXME: What is the uri scheme for zip files?
-			string uri = this.Uri + "#" + children.Name;
+			Uri uri = new Uri (this.Uri.ToString () + "#" + children.Name);
 			return uri;
 		}
 
@@ -80,7 +80,7 @@
 		override public void AddToStream (Stream stream, EventTracker tracker)
 		{
 			if (tracker != null)
-				tracker.ExpectingAdded (this.Uri);
+				tracker.ExpectingAdded (UriFu.UriToEscapedString (this.Uri));
 
 			UnclosableStream unclosable;
 			unclosable = new UnclosableStream (stream);



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