f-spot r4616 - in branches/FSPOT_0_5_0_STABLE: . extensions/Tools extensions/Tools/HashJob src/Core



Author: sdelcroix
Date: Mon Nov 24 13:10:54 2008
New Revision: 4616
URL: http://svn.gnome.org/viewvc/f-spot?rev=4616&view=rev

Log:
yet another round of fixes for md5

2008-11-24  Lorenzo Milesi  <maxxer yetopen it>

	* src/Core/Photo.cs: ensure md5 is hashed when creating new version
	with SaveVersion.


2008-11-24  Lorenzo Milesi  <maxxer yetopen it>

	* HashJob/HashJob.cs: check for missing hashes in photo versions, and
	check for empty strings also, not only for null (to work on db 16.3).
	display some feedback when pressing buttons.
	* HashJob/HashJob.addin.xml: bump ver. fix bgo#558671.

Modified:
   branches/FSPOT_0_5_0_STABLE/ChangeLog
   branches/FSPOT_0_5_0_STABLE/extensions/Tools/ChangeLog
   branches/FSPOT_0_5_0_STABLE/extensions/Tools/HashJob/HashJob.addin.xml
   branches/FSPOT_0_5_0_STABLE/extensions/Tools/HashJob/HashJob.cs
   branches/FSPOT_0_5_0_STABLE/src/Core/Photo.cs

Modified: branches/FSPOT_0_5_0_STABLE/extensions/Tools/HashJob/HashJob.addin.xml
==============================================================================
--- branches/FSPOT_0_5_0_STABLE/extensions/Tools/HashJob/HashJob.addin.xml	(original)
+++ branches/FSPOT_0_5_0_STABLE/extensions/Tools/HashJob/HashJob.addin.xml	Mon Nov 24 13:10:54 2008
@@ -1,6 +1,6 @@
 <Addin namespace="FSpot"
 	id="HashJob"
-	version="0.5.0.0"
+	version="0.5.0.1"
 	description="Process your photo collection for duplicate detection"
 	author="Stephane Delcroix"
 	url="http://f-spot.org/Extensions";

Modified: branches/FSPOT_0_5_0_STABLE/extensions/Tools/HashJob/HashJob.cs
==============================================================================
--- branches/FSPOT_0_5_0_STABLE/extensions/Tools/HashJob/HashJob.cs	(original)
+++ branches/FSPOT_0_5_0_STABLE/extensions/Tools/HashJob/HashJob.cs	Mon Nov 24 13:10:54 2008
@@ -15,7 +15,6 @@
 using Gtk;
 
 using FSpot;
-using FSpot.UI.Dialog;
 using FSpot.Extensions;
 using FSpot.Jobs;
 
@@ -31,14 +30,37 @@
 
 	public class HashJobDialog : Dialog 
 	{
+		private Gtk.Label status_label;
 
 		public void ShowDialog ()
 		{ 			
+			// This query is not very fast, but it's a 'one-time' so don't care much...
+			SqliteDataReader reader = FSpot.Core.Database.Database.Query (
+				"SELECT COUNT(*) FROM photos p WHERE md5_sum IS NULL OR md5_sum = '' OR EXISTS " +
+					"(SELECT * FROM photo_versions pv WHERE p.id=pv.photo_id AND version_id <> '1' AND " +
+					"(pv.md5_sum IS NULL OR pv.md5_sum = ''))");
+			reader.Read ();
+			uint missing_md5 = Convert.ToUInt32 (reader[0]);
+			reader.Close ();
+
+			reader = FSpot.Core.Database.Database.Query (String.Format (
+				"SELECT COUNT(*) FROM jobs WHERE job_type = '{0}' ", typeof(FSpot.Jobs.CalculateHashJob).ToString ()));
+			reader.Read ();
+			uint active_jobs = Convert.ToUInt32 (reader[0]);
+			reader.Close ();
+
 			VBox.Spacing = 6;
-			Label l = new Label ("In order to detect duplicates on pictures you imported before f-spot 0.5.0, f-spot need to analyze your image collection. This is is not done by default as it's time consuming. You can Start or Pause this update process using this dialog."); 
+			Label l = new Label (Catalog.GetString ("In order to detect duplicates on pictures you imported before 0.5.0, " +
+					"F-Spot needs to analyze your image collection. This is is not done by default as it's time consuming. " +
+					"You can Start or Pause this update process using this dialog."));
 			l.LineWrap = true;
 			VBox.PackStart (l);
 
+			Label l2 = new Label (Catalog.GetString (String.Format ("You currently have {0} photos needing md5 calculation, and {1} pending jobs",
+				missing_md5, active_jobs)));
+			l2.LineWrap = true;
+			VBox.PackStart (l2);
+
 			Button execute = new Button (Stock.Execute);
 			execute.Clicked += HandleExecuteClicked;
 			VBox.PackStart (execute);
@@ -47,11 +69,13 @@
 			stop.Clicked += HandleStopClicked;
 			VBox.PackStart (stop);
 
+			status_label = new Label ();
+			VBox.PackStart (status_label);
+
 			this.AddButton ("_Close", ResponseType.Close);
 			this.Response += HandleResponse;
 
 			ShowAll ();
-
 		}
 
 		void HandleResponse (object obj, ResponseArgs args)
@@ -66,18 +90,24 @@
 
 		void HandleExecuteClicked (object o, EventArgs e)
 		{
-			SqliteDataReader reader = FSpot.Core.Database.Database.Query ("SELECT id from photos WHERE md5_sum IS NULL");
+			SqliteDataReader reader = FSpot.Core.Database.Database.Query (
+				"SELECT id FROM photos p WHERE md5_sum IS NULL OR md5_sum = '' OR EXISTS " +
+					"(SELECT * FROM photo_versions pv WHERE p.id=pv.photo_id AND version_id <> '1' AND " +
+					"(pv.md5_sum IS NULL OR pv.md5_sum = '') )");
 			FSpot.Core.Database.Database.BeginTransaction ();
 			while (reader.Read ())
 				FSpot.Jobs.CalculateHashJob.Create (FSpot.Core.Database.Jobs, Convert.ToUInt32 (reader[0]));
 			reader.Close ();
 			FSpot.Core.Database.Database.CommitTransaction ();
+			status_label.Text = Catalog.GetString ("Processing images...");
 		}
 
 		void HandleStopClicked (object o, EventArgs e)
 		{
 			FSpot.Core.Database.Database.ExecuteNonQuery (String.Format ("DELETE FROM jobs WHERE job_type = '{0}'", typeof(FSpot.Jobs.CalculateHashJob).ToString ()));
+			status_label.Text = Catalog.GetString ("Stopped");
 		}
+
 	}
 
 }

Modified: branches/FSPOT_0_5_0_STABLE/src/Core/Photo.cs
==============================================================================
--- branches/FSPOT_0_5_0_STABLE/src/Core/Photo.cs	(original)
+++ branches/FSPOT_0_5_0_STABLE/src/Core/Photo.cs	Mon Nov 24 13:10:54 2008
@@ -359,6 +359,7 @@
 					using (Stream stream = System.IO.File.OpenWrite (version_path)) {
 						img.Save (buffer, stream);
 					}
+					(GetVersion (version) as PhotoVersion).MD5Sum = GenerateMD5 (VersionUri (version));
 					FSpot.ThumbnailGenerator.Create (version_path).Dispose ();
 					DefaultVersionId = version;
 				} catch (System.Exception e) {
@@ -446,18 +447,7 @@
 					XferOverwriteMode.Abort, 
 					delegate (Gnome.Vfs.XferProgressInfo info) {return 1;});
 	
-	//			Mono.Unix.Native.Stat stat;
-	//			int stat_err = Mono.Unix.Native.Syscall.stat (original_path, out stat);
-	//			File.Copy (original_path, new_path);
 				FSpot.ThumbnailGenerator.Create (new_uri).Dispose ();
-	//			
-	//			if (stat_err == 0) 
-	//				try {
-	//					Mono.Unix.Native.Syscall.chown(new_path, Mono.Unix.Native.Syscall.getuid (), stat.st_gid);
-	//				} catch (Exception) {}
-	//
-			} else {
-				md5_sum = Photo.GenerateMD5 (new_uri);
 			}
 			highest_version_id ++;
 



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