[f-spot/fullfile-dupedetect: 2/4] Only load photo dates when needed.



commit b54d099ebd8cbdf678cb36e31f0fb71805925035
Author: Ruben Vermeersch <ruben savanne be>
Date:   Thu Jun 10 00:14:02 2010 +0200

    Only load photo dates when needed.
    
    Makes import preparation massively faster. Scrolling in iconview a bit
    slower though.

 src/Import/FileImportSource.cs |   26 ++++++++++++++++----------
 1 files changed, 16 insertions(+), 10 deletions(-)
---
diff --git a/src/Import/FileImportSource.cs b/src/Import/FileImportSource.cs
index 6551b72..da139ea 100644
--- a/src/Import/FileImportSource.cs
+++ b/src/Import/FileImportSource.cs
@@ -139,22 +139,28 @@ namespace FSpot.Import
         {
             DefaultVersion = new ImportInfoVersion () {
                 BaseUri = original.GetBaseUri (),
-                        Filename = original.GetFilename ()
+                Filename = original.GetFilename ()
             };
-
-            try {
-                using (FSpot.ImageFile img = FSpot.ImageFile.Create (original)) {
-                    Time = img.Date;
-                }
-            } catch (Exception) {
-                Time = DateTime.Now;
-            }
         }
 
         public IBrowsableItemVersion DefaultVersion { get; private set; }
         public SafeUri DestinationUri { get; set; }
 
-        public System.DateTime Time { get; private set; }
+        private DateTime? time = null;
+        public System.DateTime Time { 
+            get {
+                if (!time.HasValue) {
+                    try {
+                        using (FSpot.ImageFile img = FSpot.ImageFile.Create (DefaultVersion.Uri)) {
+                            time = img.Date;
+                        }
+                    } catch (Exception) {
+                        time = DateTime.Now;
+                    }
+                }
+                return time.Value;
+            }
+        }
 
         public Tag [] Tags { get { throw new NotImplementedException (); } }
         public string Description { get { throw new NotImplementedException (); } }



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