[gnome-photos] facebook-item: Download only when the cache is empty



commit bd61a8cb86920f8540a8c71c5792a7d20b06bdaf
Author: Debarshi Ray <debarshir gnome org>
Date:   Fri May 22 08:00:11 2015 +0200

    facebook-item: Download only when the cache is empty
    
    This is what all the other implementations do, and it is better than
    needlessly downloading. Ideally we would also check whether the content
    has changed or not, but that can be implemented later.

 src/photos-facebook-item.c |   26 ++++++++++++++++----------
 1 files changed, 16 insertions(+), 10 deletions(-)
---
diff --git a/src/photos-facebook-item.c b/src/photos-facebook-item.c
index 4229d91..346185e 100644
--- a/src/photos-facebook-item.c
+++ b/src/photos-facebook-item.c
@@ -192,17 +192,23 @@ photos_facebook_item_download (PhotosBaseItem *item, GCancellable *cancellable,
 
   local_file = g_file_new_for_path (local_filename);
 
-  photos_debug (PHOTOS_DEBUG_NETWORK, "Downloading %s from Facebook to %s", higher_image->source, 
local_filename);
-  if (!g_file_copy (remote_file,
-                    local_file,
-                    G_FILE_COPY_ALL_METADATA | G_FILE_COPY_OVERWRITE,
-                    cancellable,
-                    NULL,
-                    NULL,
-                    error))
+  if (!g_file_test (local_filename, G_FILE_TEST_EXISTS))
     {
-      g_file_delete (local_file, NULL, NULL);
-      goto out;
+      photos_debug (PHOTOS_DEBUG_NETWORK,
+                    "Downloading %s from Facebook to %s",
+                    higher_image->source,
+                    local_filename);
+      if (!g_file_copy (remote_file,
+                        local_file,
+                        G_FILE_COPY_ALL_METADATA | G_FILE_COPY_OVERWRITE,
+                        cancellable,
+                        NULL,
+                        NULL,
+                        error))
+        {
+          g_file_delete (local_file, NULL, NULL);
+          goto out;
+        }
     }
 
   ret_val = local_filename;


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