+ return;
+}
+
+/**
+ * Cache a image from Ridge to the local disk
+ * \param path Path to the Ridge file, starting after /ridge/
+ * \return The local path to the cached image
+ */
+void cache_file(char *base, char *path, AWeatherPolicyType update,
+ AWeatherCacheDoneCallback callback, gpointer user_data)
+{
+ gchar *url = g_strconcat(base, path, NULL);
+ gchar *local = g_build_filename(g_get_user_cache_dir(), PACKAGE, path, NULL);
+ GFile *src = g_file_new_for_uri(url);
+ GFile *dst = g_file_new_for_path(local);
+
+ if (update == AWEATHER_ALWAYS)
+ return do_cache(src, dst, "cache forced", callback, user_data);
+
+ if (!g_file_test(local, G_FILE_TEST_EXISTS))
+ return do_cache(src, dst, "local does not exist", callback, user_data);
+
+ if (update == AWEATHER_AUTOMATIC && g_file_get_size(src) != g_file_get_size(dst))
+ return do_cache(src, dst, "size mismatch", callback, user_data);
+
+ /* No nead to cache, run the callback now and clean up */
+ callback(local, FALSE, user_data);
+ g_object_unref(src);
+ g_object_unref(dst);
+ g_free(local);
+ g_free(url);
+ return;