Multiple photo databases



I think I agree with the person who posted on the list a while back that having the photo database inside the .gnome2 directory isn't so good.    I'd personally like to be able to back up a single directory, and know that I have all my photos and metadata backed up.

Also, as I mentioned before, for my usage, I really need two or 3 different photo databases.

So I've tried my first patch:   What I did was to change the FSpot.Globals.BaseDirectory and PhotoDirectory to be writable properties, and then added two new command line arguments:  --baseDir and --photoDir.

--baseDir just sets BaseDirectory to what you give it --- this lets you put the photos.db file and other files in any directory you want.  If you aren't copying the photos into the Photos directory - this is probably all you need.

--photoDir - this sets BaseDirectory *and* PhotoDirectory to what you give it.  The idea is to have a single bundle storing all photo and metadata.  Eventually, what I'd like is to be able to move that directory to another location on another machine, and have everything work fine --- but it looks like that'll be more work.

The patch I've attached seems to work for me --- and I'm pretty sure that I haven't changed the default behaviour at all.    2 things I don't like --- I had to parse the argument list twice - since the new arguments have to be processed before the Core is created, and the original arguments have to be processed afterwards.    I'm also not 100% sure how it'll interact with server mode...   I've set it up so that the new args are only processed if we're creating a new server - however, I didn't indicate that in the usage message...

Does this look useful?   If so - should I open a bug and attach the patch to it?

Warren


diff -ur clean/f-spot-0.1.11/src/Global.cs f-spot-0.1.11/src/Global.cs
--- clean/f-spot-0.1.11/src/Global.cs	2005-12-08 12:59:56.000000000 -0500
+++ f-spot-0.1.11/src/Global.cs	2006-03-19 11:53:09.000000000 -0500
@@ -6,15 +6,24 @@
 			}
 		}
 
+		private static string baseDirectory = System.IO.Path.Combine (HomeDirectory,  System.IO.Path.Combine (".gnome2", "f-spot"));
+
 		public static string BaseDirectory {
 			get {
-				return System.IO.Path.Combine (HomeDirectory,  System.IO.Path.Combine (".gnome2", "f-spot"));
+				return baseDirectory;
+			}
+			set {
+				baseDirectory = value;
 			}
 		}
 
+		private static string photoDirectory = System.IO.Path.Combine (HomeDirectory, "Photos"); 
 		public static string PhotoDirectory {
 			get {
-				return System.IO.Path.Combine (HomeDirectory, "Photos");
+				return photoDirectory;
+			}
+			set {
+				photoDirectory = value;
 			}
 		}
 		
diff -ur clean/f-spot-0.1.11/src/main.cs f-spot-0.1.11/src/main.cs
--- clean/f-spot-0.1.11/src/main.cs	2006-02-26 17:37:08.000000000 -0500
+++ f-spot-0.1.11/src/main.cs	2006-03-19 12:16:23.000000000 -0500
@@ -27,6 +27,8 @@
 					System.Console.WriteLine ("Usage f-spot [OPTION. ..]\n");
 					System.Console.WriteLine ("  --import [uri]\t\t\timport from the given uri");
 					System.Console.WriteLine ("  --view <file>\t\t\t\tview a file or directory ");
+					System.Console.WriteLine ("  --baseDir <dir>\t\t\t\tput the photo database in <dir>");
+					System.Console.WriteLine ("  --photoDir <dir>\t\t\t\tput photos and database in <dir>");
 					System.Console.WriteLine ("  --shutdown\t\t\t\tshutdown a running f-spot server");
 					System.Console.WriteLine ("  --slideshow\t\t\t\tdisplay a slideshow");
 					System.Console.WriteLine ("  --debug\t\t\t\trun f-spot with mono in debug mode");
@@ -64,8 +66,29 @@
 			} catch (System.Exception e) { 
 				System.Console.WriteLine ("Starting new FSpot server");
 			}
-			
+		
+
 			if (control == null) {
+
+		    	// These arguments must be processed before the Core is created
+				for (int i = 0; i < args.Length; i++) {
+					switch (args [i]) {
+					case "--baseDir":
+						System.Console.WriteLine ("Processing Base: ");
+						if (++i < args.Length)
+							FSpot.Global.BaseDirectory = args [i];
+					
+						break;
+					case "--photoDir":
+						System.Console.WriteLine ("Processing Photo: ");
+						if (++i < args.Length) {
+							FSpot.Global.PhotoDirectory = args [i];
+							FSpot.Global.BaseDirectory = args [i];
+						}
+						break;
+					}
+				}	
+
 				Core core = null;
 				
 				Gnome.Vfs.Vfs.Initialize ();



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