[rygel/wip/create-reference: 8/10] WIP
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel/wip/create-reference: 8/10] WIP
- Date: Wed, 10 Apr 2013 14:26:05 +0000 (UTC)
commit 35cf28d59b1270e2e28972f94a40f5550effd040
Author: Jens Georg <jensg openismus com>
Date: Wed Mar 6 17:19:59 2013 +0100
WIP
.../rygel-media-export-media-cache.vala | 4 +++-
.../rygel-media-export-sql-factory.vala | 18 ++++++++++++++----
2 files changed, 17 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 871ec9c..4e43a53 100644
--- a/src/plugins/media-export/rygel-media-export-media-cache.vala
+++ b/src/plugins/media-export/rygel-media-export-media-cache.vala
@@ -727,7 +727,8 @@ public class Rygel.MediaExport.MediaCache : Object {
object.object_update_id,
-1,
-1,
- is_guarded ? 1 : 0
+ is_guarded ? 1 : 0,
+ object.ref_id ?? null
};
if (object is MediaContainer) {
var container = object as MediaContainer;
@@ -768,6 +769,7 @@ public class Rygel.MediaExport.MediaCache : Object {
db.exec (this.sql.make (SQLString.TABLE_CLOSURE));
db.exec (this.sql.make (SQLString.INDEX_COMMON));
db.exec (this.sql.make (SQLString.TRIGGER_CLOSURE));
+ db.exec (this.sql.make (SQLString.TRIGGER_REFERENCE));
db.commit ();
db.analyze ();
this.save_reset_token (UUID.get ());
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 020158a..db3db40 100644
--- a/src/plugins/media-export/rygel-media-export-sql-factory.vala
+++ b/src/plugins/media-export/rygel-media-export-sql-factory.vala
@@ -77,7 +77,8 @@ internal enum Rygel.MediaExport.SQLString {
MAX_UPDATE_ID,
MAKE_GUARDED,
IS_GUARDED,
- UPDATE_GUARDED_OBJECT
+ UPDATE_GUARDED_OBJECT,
+ TRIGGER_REFERENCE
}
internal class Rygel.MediaExport.SQLFactory : Object {
@@ -94,8 +95,8 @@ internal class Rygel.MediaExport.SQLFactory : Object {
"INSERT OR REPLACE INTO Object " +
"(upnp_id, title, type_fk, parent, timestamp, uri, " +
"object_update_id, deleted_child_count, container_update_id, " +
- "is_guarded) VALUES " +
- "(?,?,?,?,?,?,?,?,?,?)";
+ "is_guarded, reference_id) VALUES " +
+ "(?,?,?,?,?,?,?,?,?,?,?)";
private const string UPDATE_GUARDED_OBJECT_STRING =
"UPDATE Object SET " +
@@ -186,7 +187,7 @@ internal class Rygel.MediaExport.SQLFactory : Object {
"WHERE _column IS NOT NULL %s ORDER BY _column COLLATE CASEFOLD " +
"LIMIT ?,?";
- internal const string SCHEMA_VERSION = "13";
+ internal const string SCHEMA_VERSION = "14";
internal const string CREATE_META_DATA_TABLE_STRING =
"CREATE TABLE meta_data (size INTEGER NOT NULL, " +
"mime_type TEXT NOT NULL, " +
@@ -261,6 +262,13 @@ internal class Rygel.MediaExport.SQLFactory : Object {
"DELETE FROM meta_data WHERE meta_data.object_fk = OLD.upnp_id; "+
"END;";
+ private const string DELETE_REFERENCE_TRIGGER_STRING =
+ "CREATE TRIGGER trgr_delete_references " +
+ "BEFORE DELETE ON Object " +
+ "FOR EACH ROW BEGIN " +
+ "DELETE FROM Object WHERE OLD.upnp_id = Object.reference_id; " +
+ "END;";
+
private const string CREATE_INDICES_STRING =
"CREATE INDEX IF NOT EXISTS idx_parent on Object(parent);" +
"CREATE INDEX IF NOT EXISTS idx_object_upnp_id on Object(upnp_id);" +
@@ -350,6 +358,8 @@ internal class Rygel.MediaExport.SQLFactory : Object {
return IS_GUARDED_STRING;
case SQLString.UPDATE_GUARDED_OBJECT:
return UPDATE_GUARDED_OBJECT_STRING;
+ case SQLString.TRIGGER_REFERENCE:
+ return DELETE_REFERENCE_TRIGGER_STRING;
default:
assert_not_reached ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]