[evolution-rss] fix caching of longer urls



commit 6519a85471e26eb1c4045e4a4d1e18613e473ce4
Author: Lucian Langa <lucilanga gnome org>
Date:   Fri May 7 09:42:53 2010 +0300

    fix caching of longer urls
    
    add sha1 checksum to cached urls, as url can be longer
    than filename data wasn't cached

 src/rss.c |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)
---
diff --git a/src/rss.c b/src/rss.c
index 647e9b8..edbd188 100644
--- a/src/rss.c
+++ b/src/rss.c
@@ -6642,7 +6642,7 @@ fetch_image(gchar *url, gchar *link)
 	GError *err = NULL;
 	CamelStream *stream = NULL;
 	gchar *tmpurl = NULL;
-	gchar *result;
+	gchar *result, *safe;
 
 	g_return_val_if_fail(url != NULL, NULL);
 
@@ -6665,11 +6665,12 @@ fetch_image(gchar *url, gchar *link)
 	} else {
 		tmpurl = g_strdup(url);
 	}
-	d("fetch_image() tmpurl:%s\n", tmpurl);
-	stream = rss_cache_get(tmpurl);
+	safe = g_compute_checksum_for_string (
+		G_CHECKSUM_SHA1, tmpurl, -1);
+	stream = rss_cache_get(safe);
 	if (!stream) {
 		d("image cache MISS\n");
-		stream = rss_cache_add(tmpurl);
+		stream = rss_cache_add(safe);
 	} else
 		d("image cache HIT\n");
 
@@ -6680,9 +6681,15 @@ fetch_image(gchar *url, gchar *link)
 				stream,
 				0,
 				&err);
-	if (err) return NULL;
-	result = rss_cache_get_path(FALSE, tmpurl);
+	if (err) {
+		g_free(tmpurl);
+		g_free(safe);
+		return NULL;
+	}
+	result = rss_cache_get_path(FALSE, safe);
+	g_print("result:%s\n", result);
 	g_free(tmpurl);
+	g_free(safe);
 	return result;
 }
 



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