[eog] EogThumbnail: Fix incorrect file not found warning



commit 9004ceb548ff8815aa64e3f8c3d727c8b7077dfa
Author: Felix Riemann <friemann gnome org>
Date:   Fri Sep 7 23:39:46 2018 +0200

    EogThumbnail: Fix incorrect file not found warning
    
    If a large size thumbnail is already present eog would assume the normal
    sized one could be opened as well. This would cause a warning to be printed
    on the console if it is missing.
    
    Fixes #10.

 src/eog-thumbnail.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)
---
diff --git a/src/eog-thumbnail.c b/src/eog-thumbnail.c
index 2cc6fdf0..8fd2c7cf 100644
--- a/src/eog-thumbnail.c
+++ b/src/eog-thumbnail.c
@@ -53,7 +53,6 @@ typedef struct {
        char    *thumb_path;
        time_t   mtime;
        char    *mime_type;
-       gboolean thumb_exists;
        gboolean failed_thumb_exists;
        gboolean can_read;
 } EogThumbData;
@@ -93,15 +92,16 @@ get_valid_thumbnail (EogThumbData *data, GError **error)
 
        g_return_val_if_fail (data != NULL, NULL);
 
-       /* does a thumbnail under the path exists? */
-       if (data->thumb_exists) {
-               thumb = gdk_pixbuf_new_from_file (data->thumb_path, error);
+       thumb = gdk_pixbuf_new_from_file (data->thumb_path, error);
 
-               /* is this thumbnail file up to date? */
-               if (thumb != NULL && !gnome_desktop_thumbnail_is_valid (thumb, data->uri_str, data->mtime)) {
-                       g_object_unref (thumb);
-                       thumb = NULL;
-               }
+       /* It's no error if the thumbnail does not exist */
+       if (error && g_error_matches (*error, G_FILE_ERROR, G_FILE_ERROR_NOENT))
+               g_clear_error (error);
+
+       /* is this thumbnail file up to date? */
+       if (thumb != NULL && !gnome_desktop_thumbnail_is_valid (thumb, data->uri_str, data->mtime)) {
+               g_object_unref (thumb);
+               thumb = NULL;
        }
 
        return thumb;
@@ -178,8 +178,6 @@ eog_thumb_data_new (GFile *file, GError **error)
                                                                G_FILE_ATTRIBUTE_TIME_MODIFIED);
                data->mime_type = g_strdup (g_file_info_get_content_type (file_info));
 
-               data->thumb_exists = (g_file_info_get_attribute_byte_string (file_info,
-                                                                            G_FILE_ATTRIBUTE_THUMBNAIL_PATH) 
!= NULL);
                data->failed_thumb_exists = g_file_info_get_attribute_boolean (file_info,
                                                                               
G_FILE_ATTRIBUTE_THUMBNAILING_FAILED);
                data->can_read = TRUE;


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