[gnome-software] trivial: Include a SHA1 hash of the URL when saving remote icons to the cache
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] trivial: Include a SHA1 hash of the URL when saving remote icons to the cache
- Date: Tue, 26 Jul 2016 08:23:01 +0000 (UTC)
commit 9226278ab0019ddf48ec4a1c1ba434a5feb7215e
Author: Richard Hughes <richard hughsie com>
Date: Tue Jul 26 09:18:31 2016 +0100
trivial: Include a SHA1 hash of the URL when saving remote icons to the cache
This avoids any clashes if two webapps or remotes have the same icon basename.
src/plugins/gs-plugin-icons.c | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
---
diff --git a/src/plugins/gs-plugin-icons.c b/src/plugins/gs-plugin-icons.c
index ec7919b..7b3901e 100644
--- a/src/plugins/gs-plugin-icons.c
+++ b/src/plugins/gs-plugin-icons.c
@@ -130,6 +130,16 @@ gs_plugin_icons_load_local (GsPlugin *plugin, AsIcon *icon, GError **error)
size, size, error);
}
+static gchar *
+gs_plugin_icons_get_cache_fn (AsIcon *icon)
+{
+ g_autofree gchar *checksum = NULL;
+ checksum = g_compute_checksum_for_string (G_CHECKSUM_SHA1,
+ as_icon_get_url (icon),
+ -1);
+ return g_strdup_printf ("%s-%s", checksum, as_icon_get_name (icon));
+}
+
static GdkPixbuf *
gs_plugin_icons_load_remote (GsPlugin *plugin, AsIcon *icon, GError **error)
{
@@ -148,8 +158,12 @@ gs_plugin_icons_load_remote (GsPlugin *plugin, AsIcon *icon, GError **error)
/* set cache filename if not already set */
if (as_icon_get_filename (icon) == NULL) {
g_autofree gchar *fn_cache = NULL;
+ g_autofree gchar *fn_basename = NULL;
+
+ /* use a hash-prefixed filename to avoid cache clashes */
+ fn_basename = gs_plugin_icons_get_cache_fn (icon);
fn_cache = gs_utils_get_cache_filename ("icons",
- as_icon_get_name (icon),
+ fn_basename,
GS_UTILS_CACHE_FLAG_WRITEABLE,
error);
if (fn_cache == NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]