From ea6ae9b9e68db5ca5e2bb8b342372cdff34fa969 Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Tue, 20 Oct 2009 17:28:42 +0200 Subject: [PATCH] Store cached files in subfolders --- extensions/web-cache.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/extensions/web-cache.c b/extensions/web-cache.c index 946fa7a4..8f439e81 100644 --- a/extensions/web-cache.c +++ b/extensions/web-cache.c @@ -26,18 +26,23 @@ web_cache_get_cached_path (const gchar* cache_path, const gchar* uri) { gchar* checksum; + gchar* folder; + gchar* sub_path; gchar* extension; gchar* cached_filename; gchar* cached_path; - g_mkdir_with_parents (cache_path, 0700); checksum = g_compute_checksum_for_string (G_CHECKSUM_MD5, uri, -1); + folder = g_strdup_printf ("%c%c", checksum[0], checksum[1]); + sub_path = g_build_path (G_DIR_SEPARATOR_S, cache_path, folder, NULL); + g_mkdir (sub_path, 0700); + g_free (folder); extension = g_strrstr (uri, "."); cached_filename = g_strdup_printf ("%s%s", checksum, extension ? extension : ""); g_free (checksum); - cached_path = g_build_filename (cache_path, cached_filename, NULL); + cached_path = g_build_filename (sub_path, cached_filename, NULL); g_free (cached_filename); return cached_path; } -- 2.39.5