[rygel] media-export: Fix title preserving
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] media-export: Fix title preserving
- Date: Fri, 5 Apr 2013 12:56:29 +0000 (UTC)
commit ec595e8968e116d708ecce273c6e6e333492467a
Author: Jens Georg <jensg openismus com>
Date: Wed Mar 13 10:08:59 2013 +0100
media-export: Fix title preserving
Prefer the title of provided by CreateObject instead of the one deduced from
the file.
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=683926
.../rygel-media-export-media-cache.vala | 55 +++++++++++++++++++-
.../rygel-media-export-sql-factory.vala | 13 +++--
2 files changed, 63 insertions(+), 5 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 f39d690..084e9c0 100644
--- a/src/plugins/media-export/rygel-media-export-media-cache.vala
+++ b/src/plugins/media-export/rygel-media-export-media-cache.vala
@@ -519,6 +519,21 @@ public class Rygel.MediaExport.MediaCache : Object {
}
// Private functions
+ private bool is_object_guarded (string id) {
+ try {
+ GLib.Value[] id_value = { id };
+
+ return this.query_value (SQLString.IS_GUARDED,
+ id_value) == 1;
+ } catch (DatabaseError error) {
+ warning ("Failed to get whether item %s is guarded: %s",
+ id,
+ error.message);
+
+ return false;
+ }
+ }
+
private void get_exists_cache () throws DatabaseError {
this.exists_cache = new HashMap<string, ExistsCacheEntry?> ();
var cursor = this.exec_cursor (SQLString.EXISTS_CACHE);
@@ -648,6 +663,38 @@ public class Rygel.MediaExport.MediaCache : Object {
this.db.exec (this.sql.make (SQLString.SAVE_METADATA), values);
}
+ private void update_guarded_object (MediaObject object) throws Error {
+ int type = ObjectType.CONTAINER;
+ GLib.Value parent;
+
+ if (object is MediaItem) {
+ type = ObjectType.ITEM;
+ }
+
+ if (object.parent == null) {
+ parent = Database null ();
+ } else {
+ parent = object.parent.id;
+ }
+
+ GLib.Value[] values = { type,
+ parent,
+ object.modified,
+ object.uris.is_empty ? null : object.uris[0],
+ object.object_update_id,
+ -1,
+ -1,
+ object.id
+ };
+ if (object is MediaContainer) {
+ var container = object as MediaContainer;
+ values[6] = container.total_deleted_child_count;
+ values[7] = container.update_id;
+ }
+
+ this.db.exec (this.sql.make (SQLString.UPDATE_GUARDED_OBJECT), values);
+ }
+
private void create_normal_object (MediaObject object,
bool is_guarded) throws Error {
int type = ObjectType.CONTAINER;
@@ -688,7 +735,13 @@ public class Rygel.MediaExport.MediaCache : Object {
*/
private void create_object (MediaObject object,
bool override_guarded = false) throws Error {
- this.create_normal_object (object, false);
+ var is_guarded = this.is_object_guarded (object.id);
+
+ if (!override_guarded && is_guarded) {
+ update_guarded_object (object);
+ } else {
+ create_normal_object (object, (is_guarded || override_guarded));
+ }
}
/**
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 8bc8fff..42b6201 100644
--- a/src/plugins/media-export/rygel-media-export-sql-factory.vala
+++ b/src/plugins/media-export/rygel-media-export-sql-factory.vala
@@ -97,10 +97,15 @@ internal class Rygel.MediaExport.SQLFactory : Object {
"(?,?,?,?,?,?,?,?,?,?)";
private const string UPDATE_GUARDED_OBJECT_STRING =
- "REPLACE INTO Object " +
- "(upnp_id, type_fk, parent, timestamp, uri, " +
- "object_update_id, deleted_child_count, container_update_id) " +
- "VALUES (?,?,?,?,?,?,?,?)";
+ "UPDATE Object SET " +
+ "type_fk = ?, " +
+ "parent = ?, " +
+ "timestamp = ?, " +
+ "uri = ?, " +
+ "object_update_id = ?, " +
+ "deleted_child_count = ?, " +
+ "container_update_id = ? " +
+ "where upnp_id = ?";
private const string DELETE_BY_ID_STRING =
"DELETE FROM Object WHERE upnp_id IN " +
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]