]> Pileus Git - grits/blobdiff - src/data/gis-http.c
Move cache name building to separate function
[grits] / src / data / gis-http.c
index 0765415f3e974d87c42d4879d63a663274cd7974..739792a57a33669f180257aaf6cab4d511b412a2 100644 (file)
 
 #include "gis-http.h"
 
+gchar *_get_cache_path(GisHttp *http, const gchar *local)
+{
+       return g_build_filename(g_get_user_cache_dir(), PACKAGE,
+                       http->prefix, local, NULL);
+}
+
 /**
  * gis_http_new:
  * @prefix: The prefix in the cache to store the downloaded files.
@@ -117,11 +123,10 @@ static void _chunk_cb(SoupMessage *message, SoupBuffer *chunk, gpointer _info)
 gchar *gis_http_fetch(GisHttp *http, const gchar *uri, const char *local,
                GisCacheType mode, GisChunkCallback callback, gpointer user_data)
 {
-       g_debug("GisHttp: fetch - %.20s... >> %s/%s  mode=%d",
+       g_debug("GisHttp: fetch - %s... >> %s/%s  mode=%d",
                        uri, http->prefix, local, mode);
 
-       gchar *path = g_build_filename(g_get_user_cache_dir(), PACKAGE,
-                       http->prefix, local, NULL);
+       gchar *path = _get_cache_path(http, local);
 
        /* Unlink the file if we're refreshing it */
        if (mode == GIS_REFRESH)
@@ -130,7 +135,7 @@ gchar *gis_http_fetch(GisHttp *http, const gchar *uri, const char *local,
        /* Do the cache if necessasairy */
        if (!(mode == GIS_ONCE && g_file_test(path, G_FILE_TEST_EXISTS)) &&
                        mode != GIS_LOCAL) {
-               g_debug("GisHttp: do_cache - Caching file %s", local);
+               g_debug("GisHttp: fetch - Caching file %s", local);
 
                /* Open the file for writting */
                gchar *part = path;