[goobox] make sure the cache directory exists before saving the file
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goobox] make sure the cache directory exists before saving the file
- Date: Tue, 6 Jul 2010 08:02:27 +0000 (UTC)
commit 5c537013a34fb9952f296b696dfef91428ecbabe
Author: Paolo Bacchilega <paobac src gnome org>
Date: Tue Jul 6 10:00:15 2010 +0200
make sure the cache directory exists before saving the file
[bug #623607]
src/album-info.c | 7 +++++++
src/goo-player.c | 18 +++++++++++-------
2 files changed, 18 insertions(+), 7 deletions(-)
---
diff --git a/src/album-info.c b/src/album-info.c
index a0e7c5d..10c3bc8 100644
--- a/src/album-info.c
+++ b/src/album-info.c
@@ -433,10 +433,17 @@ album_info_save_to_cache (AlbumInfo *album,
path = get_cache_path (album, disc_id);
if (path != NULL) {
+ char *dir;
+
+ dir = g_path_get_dirname (path);
+ g_mkdir_with_parents (dir, 0700);
+
if (! g_file_set_contents (path, data, length, &error)) {
debug (DEBUG_INFO, "%s\n", error->message);
g_clear_error (&error);
}
+
+ g_free (dir);
g_free (path);
}
g_free (data);
diff --git a/src/goo-player.c b/src/goo-player.c
index a4a99ec..3c9c3b0 100644
--- a/src/goo-player.c
+++ b/src/goo-player.c
@@ -167,15 +167,16 @@ update_progress_cb (gpointer user_data)
self->priv->update_progress_id = 0;
}
- if (! gst_pad_query_position (self->priv->source_pad,
- &self->priv->sector_format,
- §or))
+ if ((self->priv->current_track == NULL)
+ || ! gst_pad_query_position (self->priv->source_pad,
+ &self->priv->sector_format,
+ §or))
{
return FALSE;
}
g_signal_emit_by_name (G_OBJECT (self),
- "progress",
+ "progress",
((double) sector) / (double) self->priv->current_track->sectors,
NULL);
@@ -488,10 +489,8 @@ set_cd_metadata_from_rdf (GooPlayer *self,
static char *
get_cached_rdf_path (GooPlayer *self)
{
- if (self->priv->discid != NULL) {
- gth_user_dir_make_dir_for_file (GTH_DIR_CACHE, "goobox", self->priv->discid, NULL);
+ if (self->priv->discid != NULL)
return gth_user_dir_get_file (GTH_DIR_CACHE, "goobox", self->priv->discid, NULL);
- }
else
return NULL;
}
@@ -502,6 +501,7 @@ save_rdf_to_cache (GooPlayer *player,
const char *rdf)
{
char *path;
+ char *dir;
GError *error = NULL;
if (rdf == NULL)
@@ -516,11 +516,15 @@ save_rdf_to_cache (GooPlayer *player,
return;
}
+ dir = g_path_get_dirname (path);
+ g_mkdir_with_parents (dir, 0700);
+
if (! g_file_set_contents (path, rdf, strlen (rdf), &error)) {
debug (DEBUG_INFO, "%s\n", error->message);
g_clear_error (&error);
}
+ g_free (dir);
g_free (path);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]