Commit 22d260e316fa422f3ef14e1c146cb04da38f6f60

Use default cache path when not specified.

Signed-off-by: Jiří Techet <techet@gmail.com>
champlain/champlain-file-cache.c
(28 / 9)
  
7070static gboolean tile_is_expired (ChamplainFileCache *file_cache, ChamplainTile *tile);
7171static void delete_tile (ChamplainFileCache *file_cache, const gchar *filename);
7272static void delete_dir_recursive (GFile *parent);
73static gboolean create_cache_dir (const gchar *dir_name);
7374
7475static void fill_tile (ChamplainMapSource *map_source,
7576 ChamplainTile *tile);
199199 G_OBJECT_CLASS (champlain_file_cache_parent_class)->finalize (object);
200200}
201201
202static gboolean
203create_cache_dir (const gchar *dir_name)
204{
205 /* If needed, create the cache's dirs */
206 if (dir_name)
207 {
208 if (g_mkdir_with_parents (dir_name, 0700) == -1 && errno != EEXIST)
209 {
210 g_warning ("Unable to create the image cache path '%s': %s",
211 dir_name, g_strerror (errno));
212 return FALSE;
213 }
214 }
215 return TRUE;
216}
217
202218static void
203219init_cache (ChamplainFileCache *file_cache)
204220{
225225 gint error;
226226
227227 g_print ("init! '%d'\n", champlain_tile_cache_get_persistent (tile_cache));
228 /* If needed, create the cache's dirs */
229 if (priv->cache_dir)
228
229 g_return_if_fail (create_cache_dir (priv->cache_dir));
230
231 if (champlain_tile_cache_get_persistent (tile_cache))
230232 {
231 if (g_mkdir_with_parents (priv->cache_dir, 0700) == -1 && errno != EEXIST)
233 if (priv->cache_dir)
234 priv->real_cache_dir = g_strdup (priv->cache_dir);
235 else
232236 {
233 g_warning ("Unable to create the image cache path '%s': %s",
234 priv->cache_dir, g_strerror (errno));
235 return;
237 priv->real_cache_dir = g_build_path (G_DIR_SEPARATOR_S,
238 g_get_user_cache_dir (),
239 "champlain", NULL);
240 g_return_if_fail (create_cache_dir (priv->real_cache_dir));
236241 }
237242 }
238
239 if (champlain_tile_cache_get_persistent (tile_cache))
240 priv->real_cache_dir = g_strdup (priv->cache_dir);
241243 else
242244 {
243245 /* Create temporary directory for non-persistent caches */

Comments

Add a new comment:

Login or create an account to post a comment

Add your comment