[f-spot] Keep an ID instead of a reference on import.



commit 21467dd3a944ac0f517a0727fbd157b1f2d3d4dc
Author: Ruben Vermeersch <ruben savanne be>
Date:   Sun May 16 11:39:45 2010 +0200

    Keep an ID instead of a reference on import.
    
    Photos were kept around for rollback purposes. We can be much more
    efficient in memory by simply keeping the ID and retrieving photos when
    needed.

 src/FileImportBackend.cs |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/src/FileImportBackend.cs b/src/FileImportBackend.cs
index 7f7bd45..3a1690b 100644
--- a/src/FileImportBackend.cs
+++ b/src/FileImportBackend.cs
@@ -58,7 +58,7 @@ public class FileImportBackend : ImportBackend {
 		public string Name { get { throw new NotImplementedException (); } }
 		public uint Rating { get { return 0; } }
 
-		internal Photo Photo { get; set; }
+		internal uint PhotoId { get; set; }
 	}
 
 	public override List<IBrowsableItem> Prepare ()
@@ -225,7 +225,7 @@ public class FileImportBackend : ImportBackend {
 				if (needs_commit)
 					store.Commit(photo);
 
-                info.Photo = photo;
+                info.PhotoId = photo.Id;
 			}
 		} catch (System.Exception e) {
 			System.Console.WriteLine ("Error importing {0}{2}{1}", info.DestinationUri.ToString (), e.ToString (), Environment.NewLine);
@@ -278,8 +278,8 @@ public class FileImportBackend : ImportBackend {
 				}
 			}
 			
-			if (info.Photo != null)
-				store.Remove (info.Photo);
+			if (info.PhotoId != 0)
+				store.Remove (store.Get (info.PhotoId));
 		}
 		
 		// clean up all the directories we created.
@@ -306,8 +306,8 @@ public class FileImportBackend : ImportBackend {
 			throw new ImportException ("Not doing anything");
 
 		foreach (ImportInfo info in import_info) {
-			if (info.Photo != null) 
-				FSpot.ThumbnailGenerator.Default.Request (info.Photo.DefaultVersionUri, 0, 256, 256);
+			if (info.PhotoId != 0) 
+				FSpot.ThumbnailGenerator.Default.Request (store.Get (info.PhotoId).DefaultVersionUri, 0, 256, 256);
 		}
 
 		import_info = null;



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