f-spot r4177 - trunk/src



Author: sdelcroix
Date: Mon Jul 14 14:00:27 2008
New Revision: 4177
URL: http://svn.gnome.org/viewvc/f-spot?rev=4177&view=rev

Log:
drop Query by DirectoryInfo, replace it by Query by Uri, fix a bug in dup detection


Modified:
   trunk/src/FileImportBackend.cs
   trunk/src/PhotoStore.cs

Modified: trunk/src/FileImportBackend.cs
==============================================================================
--- trunk/src/FileImportBackend.cs	(original)
+++ trunk/src/FileImportBackend.cs	Mon Jul 14 14:00:27 2008
@@ -74,20 +74,19 @@
 
 	private void GetListing (System.IO.DirectoryInfo dirinfo, System.IO.FileInfo [] files, bool recurse)
 	{
-		System.Console.WriteLine ("Scanning {0}", dirinfo.FullName);
+		Log.DebugFormat ("Scanning {0} for new photos", dirinfo.FullName);
 		List<Uri> existing_entries = new List<Uri> ();
 
-		foreach (Photo p in store.Query (dirinfo)) {
+		foreach (Photo p in store.Query (new Uri (dirinfo.FullName)))
 			foreach (uint id in p.VersionIds) {
+				Log.DebugFormat ("found {0}", p.VersionUri (id));
 				existing_entries.Add (p.VersionUri (id));
 			}
-		}
 
-		foreach (System.IO.FileInfo f in files) {
+		foreach (System.IO.FileInfo f in files)
 			if (! existing_entries.Contains (UriUtils.PathToFileUri (f.FullName)) && !f.Name.StartsWith (".")) {
 				AddPath (f.FullName);
 			}
-		}
 
 		if (recurse) {
 			foreach (System.IO.DirectoryInfo d in dirinfo.GetDirectories ()){

Modified: trunk/src/PhotoStore.cs
==============================================================================
--- trunk/src/PhotoStore.cs	(original)
+++ trunk/src/PhotoStore.cs	Mon Jul 14 14:00:27 2008
@@ -606,9 +606,26 @@
 		return query_result.ToArray ();
 	}
 
-	[Obsolete ("No longer make any sense with uris...")]
-	public Photo [] Query (System.IO.DirectoryInfo dir)
+//	[Obsolete ("No longer make any sense with uris...")]
+//	public Photo [] Query (System.IO.DirectoryInfo dir)
+//	{
+//		return Query (new DbCommand (
+//			"SELECT photos.id, "			+
+//				"photos.time, "			+
+//				"photos.uri, "			+
+//				"photos.description, "		+
+//				"photos.roll_id, "		+
+//				"photos.default_version_id, "	+
+//				"photos.rating "		+
+//			"FROM photos " 				+
+//			"WHERE uri LIKE \"file://:dir%\" "	+
+//			"AND uri NOT LIKE \"file://:dir/%/%\"",
+//			"dir", dir.FullName ));
+//	}
+
+	public Photo [] Query (System.Uri uri)
 	{
+		Log.DebugFormat ("Query Uri {0}", uri);
 		return Query (new DbCommand (
 			"SELECT photos.id, "			+
 				"photos.time, "			+
@@ -618,9 +635,10 @@
 				"photos.default_version_id, "	+
 				"photos.rating "		+
 			"FROM photos " 				+
-			"WHERE uri LIKE \"file://:dir%\" "	+
-			"AND uri NOT LIKE \"file://:dir/%/%\"",
-			"dir", dir.FullName ));
+			"WHERE uri LIKE :uri "		+
+			"AND uri NOT LIKE :uri_",
+			"uri", uri.ToString () + "%",
+			"uri_", uri.ToString () + "/%/%"));
 	}
 
 	[Obsolete ("drop this, use IQueryCondition correctly instead")]



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