[rygel] media-export: Stop child folders from disappearing
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] media-export: Stop child folders from disappearing
- Date: Sun, 12 May 2013 11:06:03 +0000 (UTC)
commit e6f7961b1b6e64e96fc770e50a7253afdc8f1abf
Author: Jens Georg <jensg openismus com>
Date: Sun May 12 12:54:37 2013 +0200
media-export: Stop child folders from disappearing
https://bugzilla.gnome.org/show_bug.cgi?id=648003
.../rygel-media-export-media-cache.vala | 7 +++++++
.../rygel-media-export-root-container.vala | 5 ++++-
.../rygel-media-export-sql-factory.vala | 8 +++++++-
3 files changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/src/plugins/media-export/rygel-media-export-media-cache.vala
b/src/plugins/media-export/rygel-media-export-media-cache.vala
index 4e43a53..9ebfd97 100644
--- a/src/plugins/media-export/rygel-media-export-media-cache.vala
+++ b/src/plugins/media-export/rygel-media-export-media-cache.vala
@@ -95,6 +95,13 @@ public class Rygel.MediaExport.MediaCache : Object {
this.db.exec (this.sql.make (SQLString.DELETE), values);
}
+ public void remove_by_id_from_parent (string id, string parent_id)
+ throws DatabaseError {
+ GLib.Value[] values = { id, parent_id };
+ this.db.exec (this.sql.make (SQLString.DELETE_BY_ID_FROM_PARENT),
+ values);
+ }
+
public void remove_object (MediaObject object) throws DatabaseError,
MediaCacheError {
this.remove_by_id (object.id);
diff --git a/src/plugins/media-export/rygel-media-export-root-container.vala
b/src/plugins/media-export/rygel-media-export-root-container.vala
index 8da3565..286f005 100644
--- a/src/plugins/media-export/rygel-media-export-root-container.vala
+++ b/src/plugins/media-export/rygel-media-export-root-container.vala
@@ -427,8 +427,11 @@ public class Rygel.MediaExport.RootContainer : TrackableDbContainer {
foreach (var id in ids) {
debug ("ID %s is no longer in the configuration. Deleting...", id);
try {
+ // Remove IDs only if it's a parent of the toplevel folder.
+ // Keep it otherwise.
+ this.media_db.remove_by_id_from_parent (id,
+ FILESYSTEM_FOLDER_ID);
// FIXME: I think this needs to emit objDel events...
- this.media_db.remove_by_id (id);
} catch (DatabaseError error) {
warning (_("Failed to remove entry: %s"), error.message);
}
diff --git a/src/plugins/media-export/rygel-media-export-sql-factory.vala
b/src/plugins/media-export/rygel-media-export-sql-factory.vala
index db3db40..4352cc0 100644
--- a/src/plugins/media-export/rygel-media-export-sql-factory.vala
+++ b/src/plugins/media-export/rygel-media-export-sql-factory.vala
@@ -78,7 +78,8 @@ internal enum Rygel.MediaExport.SQLString {
MAKE_GUARDED,
IS_GUARDED,
UPDATE_GUARDED_OBJECT,
- TRIGGER_REFERENCE
+ TRIGGER_REFERENCE,
+ DELETE_BY_ID_FROM_PARENT
}
internal class Rygel.MediaExport.SQLFactory : Object {
@@ -304,6 +305,9 @@ internal class Rygel.MediaExport.SQLFactory : Object {
private const string IS_GUARDED_STRING =
"SELECT is_guarded FROM Object WHERE Object.upnp_id = ?";
+ private const string DELETE_BY_ID_FROM_PARENT_STRING =
+ "DELETE FROM Object WHERE upnp_id = ? AND parent = ?";
+
public unowned string make (SQLString query) {
switch (query) {
case SQLString.SAVE_METADATA:
@@ -360,6 +364,8 @@ internal class Rygel.MediaExport.SQLFactory : Object {
return UPDATE_GUARDED_OBJECT_STRING;
case SQLString.TRIGGER_REFERENCE:
return DELETE_REFERENCE_TRIGGER_STRING;
+ case SQLString.DELETE_BY_ID_FROM_PARENT:
+ return DELETE_BY_ID_FROM_PARENT_STRING;
default:
assert_not_reached ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]