]> Pileus Git - grits/blobdiff - src/data.c
pretty
[grits] / src / data.c
index fa11ea8460f03cdfb1738c89e4ccac416c182e81..06c9fbb177e8b11ae0279707dc1417d8e32de10b 100644 (file)
@@ -47,7 +47,8 @@ static void cache_file_cb(GObject *source_object, GAsyncResult *res, gpointer _i
 static goffset g_file_get_size(GFile *file)
 {
        GError *error = NULL;
-       GFileInfo *info = g_file_query_info(file, G_FILE_ATTRIBUTE_STANDARD_SIZE, 0, NULL, &error);
+       GFileInfo *info = g_file_query_info(file,
+                       G_FILE_ATTRIBUTE_STANDARD_SIZE, 0, NULL, &error);
        if (error)
                g_warning("unable to get file size: %s", error->message);
        return g_file_info_get_size(info);
@@ -70,11 +71,17 @@ void cache_file(char *base, char *path, AWeatherCacheDoneCallback callback, gpoi
        else if (g_file_get_size(src) != g_file_get_size(dst))
                g_message("Caching file: sizes mismatch - %lld != %lld",
                                g_file_get_size(src), g_file_get_size(dst));
-       else
-               return callback(local, user_data);
+       else {
+               callback(local, user_data);
+               g_free(local);
+               g_free(url);
+               return;
+       }
 
-       if (!g_file_test(g_path_get_dirname(local), G_FILE_TEST_IS_DIR))
-               g_mkdir_with_parents(g_path_get_dirname(local), 0755);
+       char *dir = g_path_get_dirname(local);
+       if (!g_file_test(dir, G_FILE_TEST_IS_DIR))
+               g_mkdir_with_parents(dir, 0755);
+       g_free(dir);
        cache_file_end_t *info = g_malloc0(sizeof(cache_file_end_t));
        info->callback  = callback;
        info->src       = url;