Deleting non-existant files



If you have photos in your f-spot database that don't exist on disk, and
you try to delete them, f-spot throws a System.IO.InvalidDirectory
exception (or something like that) which is uncaught and causes the
program to freeze. 

I've attached a patch which just wraps the code to delete files in a try
\catch block and gives you an error message for each file it could not
delete. The file is still removed from the catalog though.

Any thoughts on it?

(BTW, what is the format for generating diffs? I'm just doing "diff -u
from to")

Thanks,
Haran

-- 
I've found that you don't need to wear a neck-tie if you can hit
- Ted Williams

--- f-spot-0.0.13/src/MainWindow.cs	2005-04-20 22:19:40.000000000 +0600
+++ /home/haran/devel/f-spot/f-spot-0.0.13/src/MainWindow.cs	2005-06-25 19:41:09.466803264 +0600
@@ -1412,10 +1412,18 @@
 								 photos.Length);
 		string ok_caption = Mono.Posix.Catalog.GetPluralString ("_Delete photo", "_Delete photos", photos.Length);
 		if (ResponseType.Ok == HigMessageDialog.RunHigConfirmation(main_window, DialogFlags.DestroyWithParent, MessageType.Warning, header, msg, ok_caption)) {                              
+			string err = "";
 			foreach (Photo photo in photos) {
 				foreach (uint id in photo.VersionIds) {
-					Console.WriteLine (" path == {0}", photo.GetVersionPath (id)); 
-					photo.DeleteVersion (id, true);
+					try {
+							Console.WriteLine (" path == {0}", photo.GetVersionPath (id)); 
+							photo.DeleteVersion (id, true);
+					}
+					catch (Exception e) {
+							string hdr = Mono.Posix.Catalog.GetString("Error while deleting");
+							HigMessageDialog.RunHigMessageDialog(main_window,DialogFlags.DestroyWithParent, 
+											MessageType.Error, Gtk.ButtonsType.Ok,hdr, "Error:"+e.Message);
+					}
 				}
 
 				db.Photos.Remove (photo);


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