[rygel/rygel-0-18] media-export: Stop child folders from disappearing
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel/rygel-0-18] media-export: Stop child folders from disappearing
- Date: Mon, 13 May 2013 09:23:37 +0000 (UTC)
commit e404168c73c32d2fd5e3790507a7a70925a6da74
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
Conflicts:
src/plugins/media-export/rygel-media-export-sql-factory.vala
.../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 084e9c0..34b1bb7 100644
--- a/src/plugins/media-export/rygel-media-export-media-cache.vala
+++ b/src/plugins/media-export/rygel-media-export-media-cache.vala
@@ -87,6 +87,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 1cd62d2..2357c2a 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 42b6201..1127c61 100644
--- a/src/plugins/media-export/rygel-media-export-sql-factory.vala
+++ b/src/plugins/media-export/rygel-media-export-sql-factory.vala
@@ -76,7 +76,8 @@ internal enum Rygel.MediaExport.SQLString {
MAX_UPDATE_ID,
MAKE_GUARDED,
IS_GUARDED,
- UPDATE_GUARDED_OBJECT
+ UPDATE_GUARDED_OBJECT,
+ DELETE_BY_ID_FROM_PARENT
}
internal class Rygel.MediaExport.SQLFactory : Object {
@@ -294,6 +295,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:
@@ -348,6 +352,8 @@ internal class Rygel.MediaExport.SQLFactory : Object {
return IS_GUARDED_STRING;
case SQLString.UPDATE_GUARDED_OBJECT:
return UPDATE_GUARDED_OBJECT_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]