[PATCH 04/13] cache: Add function to remove persistent cache
- From: "Juan A. Suarez Romero" <jasuarez igalia com>
- To: grilo-list gnome org
- Subject: [PATCH 04/13] cache: Add function to remove persistent cache
- Date: Tue, 15 Feb 2011 19:07:10 +0100
Allow user to remove a persistent cache.
Signed-off-by: Juan A. Suarez Romero <jasuarez igalia com>
---
src/grl-media-cache.c | 17 +++++++++++++++++
src/grl-media-cache.h | 2 ++
2 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/src/grl-media-cache.c b/src/grl-media-cache.c
index 8bd3ad5..f86b500 100644
--- a/src/grl-media-cache.c
+++ b/src/grl-media-cache.c
@@ -77,6 +77,7 @@ enum {
struct _GrlMediaCachePrivate {
gchar *cache_id;
gboolean persistent;
+ gboolean force_db_removal;
sqlite3 *db;
};
@@ -151,6 +152,10 @@ grl_media_cache_finalize (GObject *object)
/* Free all non-gobject elements */
GRL_DEBUG (__FUNCTION__);
+ if (cache->priv->force_db_removal) {
+ remove_table (cache->priv->db, cache->priv->cache_id);
+ }
+
sqlite3_close (cache->priv->db);
g_free (cache->priv->cache_id);
@@ -300,6 +305,18 @@ grl_media_cache_new_persistent (const gchar *cache_id)
return cache;
}
+void
+grl_media_cache_destroy (GrlMediaCache *cache)
+{
+ g_return_if_fail (GRL_IS_MEDIA_CACHE (cache));
+
+ if (cache->priv->persistent) {
+ cache->priv->force_db_removal = TRUE;
+ }
+
+ g_object_unref (cache);
+}
+
gboolean
grl_media_cache_insert_media (GrlMediaCache *cache,
GrlMedia *media,
diff --git a/src/grl-media-cache.h b/src/grl-media-cache.h
index a4affc1..d160d85 100644
--- a/src/grl-media-cache.h
+++ b/src/grl-media-cache.h
@@ -92,6 +92,8 @@ GrlMediaCache *grl_media_cache_new (void);
GrlMediaCache *grl_media_cache_new_persistent (const gchar *cache_id);
+void grl_media_cache_destroy (GrlMediaCache *cache);
+
gboolean grl_media_cache_insert_media (GrlMediaCache *cache,
GrlMedia *media,
const gchar *parent,
--
1.7.4
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]