[gnome-software] Fix the icon filename if the remote icon type is JPEG



commit f1b06aafe1cebd2eaa7214abab6859da83758add
Author: Richard Hughes <richard hughsie com>
Date:   Thu Oct 1 14:23:15 2015 +0100

    Fix the icon filename if the remote icon type is JPEG

 src/plugins/gs-plugin-icons.c |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/src/plugins/gs-plugin-icons.c b/src/plugins/gs-plugin-icons.c
index be0bd35..8055b82 100644
--- a/src/plugins/gs-plugin-icons.c
+++ b/src/plugins/gs-plugin-icons.c
@@ -163,6 +163,8 @@ static gboolean
 gs_plugin_refine_app (GsPlugin *plugin, GsApp *app, GError **error)
 {
        AsIcon *ic;
+       const gchar *fn;
+       gchar *found;
 
        /* not applicable */
        ic = gs_app_get_icon (app);
@@ -171,13 +173,16 @@ gs_plugin_refine_app (GsPlugin *plugin, GsApp *app, GError **error)
        if (as_icon_get_filename (ic) == NULL)
                return TRUE;
 
+       /* convert filename from jpg to png */
+       fn = as_icon_get_filename (ic);
+       found = g_strstr_len (fn, -1, ".jpg");
+       if (found != NULL)
+               memcpy (found, ".png", 4);
+
        /* create runtime dir and download */
-       if (!gs_mkdir_parent (as_icon_get_filename (ic), error))
+       if (!gs_mkdir_parent (fn, error))
                return FALSE;
-       if (!gs_plugin_icons_download (plugin,
-                                      as_icon_get_url (ic),
-                                      as_icon_get_filename (ic),
-                                      error))
+       if (!gs_plugin_icons_download (plugin, as_icon_get_url (ic), fn, error))
                return FALSE;
        as_icon_set_kind (ic, AS_ICON_KIND_LOCAL);
        return gs_app_load_icon (app, plugin->scale, error);


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