file-info: catch thumbnail files in large directory as well
authorCosimo Cecchi <cosimoc@gnome.org>
Tue, 1 May 2012 02:39:57 +0000 (22:39 -0400)
committerCosimo Cecchi <cosimoc@gnome.org>
Fri, 26 Oct 2012 14:48:09 +0000 (10:48 -0400)
When building the file attribute table info for local files, use
thumbnail paths in $XDG_CACHE_DIR/thumbnails/large in addition to
$XDG_CACHE_DIR/thumbnails/normal.

Failing to do this would cause an application that creates large
thumbnails by default to never find any value for
G_FILE_ATTRIBUTE_THUMBNAIL_PATH, with no
G_FILE_ATTRIBUTE_THUMBNAILING_FAILED set, which might cause the
application to either think thumbnailing is still in progress, or
blindly requeue thumbnail operations in a loop.

Large thumbnails are generally preferred, so we now default to the path
of a large thumbnail (in case both are present).

https://bugzilla.gnome.org/show_bug.cgi?id=686895

gio/glocalfileinfo.c

index 1bff319..306fb58 100644 (file)
@@ -1292,7 +1292,7 @@ get_thumbnail_attributes (const char *path,
   g_checksum_free (checksum);
 
   filename = g_build_filename (g_get_user_cache_dir (),
-                               "thumbnails", "normal", basename,
+                               "thumbnails", "large", basename,
                                NULL);
 
   if (g_file_test (filename, G_FILE_TEST_IS_REGULAR))
@@ -1301,13 +1301,22 @@ get_thumbnail_attributes (const char *path,
     {
       g_free (filename);
       filename = g_build_filename (g_get_user_cache_dir (),
-                                   "thumbnails", "fail",
-                                   "gnome-thumbnail-factory",
-                                   basename,
+                                   "thumbnails", "normal", basename,
                                    NULL);
 
       if (g_file_test (filename, G_FILE_TEST_IS_REGULAR))
-       _g_file_info_set_attribute_boolean_by_id (info, G_FILE_ATTRIBUTE_ID_THUMBNAILING_FAILED, TRUE);
+        _g_file_info_set_attribute_byte_string_by_id (info, G_FILE_ATTRIBUTE_ID_THUMBNAIL_PATH, filename);
+      else
+        {
+          filename = g_build_filename (g_get_user_cache_dir (),
+                                       "thumbnails", "fail",
+                                       "gnome-thumbnail-factory",
+                                       basename,
+                                       NULL);
+
+          if (g_file_test (filename, G_FILE_TEST_IS_REGULAR))
+            _g_file_info_set_attribute_boolean_by_id (info, G_FILE_ATTRIBUTE_ID_THUMBNAILING_FAILED, TRUE);
+        }
     }
   g_free (basename);
   g_free (filename);