[gnome-photos] base-item: Clear the thumbnail path if the thumbnail is invalid



commit f247c720a939f3e559676bdfeed82fe737c56647
Author: Debarshi Ray <debarshir gnome org>
Date:   Sat Feb 8 09:59:08 2014 +0100

    base-item: Clear the thumbnail path if the thumbnail is invalid
    
    In some cases, thumbnailing might have failed even if we have a path to
    the thumbnail image. eg., the downloaded thumbnail for some remote
    content might be damaged.
    
    Clear the thumbnail path and remove the invalid file to maintain the
    invariants assumed by the code.

 src/photos-base-item.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
---
diff --git a/src/photos-base-item.c b/src/photos-base-item.c
index 79fc3f5..303d280 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -405,7 +405,12 @@ photos_base_item_refresh_thumb_path_pixbuf (GObject *source_object, GAsyncResult
   priv->icon = gdk_pixbuf_new_from_stream_finish (res, &error);
   if (error != NULL)
     {
+      GFile *file;
+
       priv->failed_thumbnailing = TRUE;
+      priv->thumb_path = NULL;
+      file = G_FILE (g_object_get_data (G_OBJECT (stream), "file"));
+      g_file_delete_async (file, G_PRIORITY_DEFAULT, NULL, NULL, NULL);
       g_error_free (error);
       goto out;
     }
@@ -432,10 +437,13 @@ photos_base_item_refresh_thumb_path_read (GObject *source_object, GAsyncResult *
   if (error != NULL)
     {
       priv->failed_thumbnailing = TRUE;
+      priv->thumb_path = NULL;
+      g_file_delete_async (file, G_PRIORITY_DEFAULT, NULL, NULL, NULL);
       g_error_free (error);
       goto out;
     }
 
+  g_object_set_data_full (G_OBJECT (stream), "file", g_object_ref (file), g_object_unref);
   size = photos_utils_get_icon_size ();
   gdk_pixbuf_new_from_stream_at_scale_async (G_INPUT_STREAM (stream),
                                              size,


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