[rygel] media-export: Get rid of obsolete flags column in object table.



commit 27fcf9618a93a22e2244038e32f6f6cc961fff7b
Author: Krzesimir Nowak <krnowak openismus com>
Date:   Fri Mar 1 12:15:43 2013 +0100

    media-export: Get rid of obsolete flags column in object table.
    
    DBus interface was using it, but it is gone since 0.17.7.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=694926

 .../media-export/rygel-media-export-harvester.vala |    7 +--
 .../rygel-media-export-harvesting-task.vala        |   12 +----
 .../rygel-media-export-media-cache-upgrader.vala   |   52 ++++++++++++++++++--
 .../rygel-media-export-media-cache.vala            |   19 -------
 .../rygel-media-export-sql-factory.vala            |    1 -
 5 files changed, 50 insertions(+), 41 deletions(-)
---
diff --git a/src/plugins/media-export/rygel-media-export-harvester.vala 
b/src/plugins/media-export/rygel-media-export-harvester.vala
index 153f1d2..5f3f67a 100644
--- a/src/plugins/media-export/rygel-media-export-harvester.vala
+++ b/src/plugins/media-export/rygel-media-export-harvester.vala
@@ -81,11 +81,9 @@ internal class Rygel.MediaExport.Harvester : GLib.Object {
      *
      * @param file the file to investigate
      * @param parent container of the filer to be harvested
-     * @param flag optional flag for the container to set in the database
      */
     public void schedule (File           file,
-                          MediaContainer parent,
-                          string?        flag = null) {
+                          MediaContainer parent) {
         this.extraction_grace_timers.unset (file);
 
         // Cancel a probably running harvester
@@ -93,8 +91,7 @@ internal class Rygel.MediaExport.Harvester : GLib.Object {
 
         var task = new HarvestingTask (this.monitor,
                                        file,
-                                       parent,
-                                       flag);
+                                       parent);
         task.cancellable = this.cancellable;
         task.completed.connect (this.on_file_harvested);
         this.tasks[file] = task;
diff --git a/src/plugins/media-export/rygel-media-export-harvesting-task.vala 
b/src/plugins/media-export/rygel-media-export-harvesting-task.vala
index 277c3e5..b9d4fba 100644
--- a/src/plugins/media-export/rygel-media-export-harvesting-task.vala
+++ b/src/plugins/media-export/rygel-media-export-harvesting-task.vala
@@ -42,7 +42,6 @@ public class Rygel.MediaExport.HarvestingTask : Rygel.StateMachine,
     private GLib.Queue<MediaContainer> containers;
     private Gee.Queue<FileQueueEntry> files;
     private RecursiveFileMonitor monitor;
-    private string flag;
     private MediaContainer parent;
     private const int BATCH_SIZE = 256;
 
@@ -58,8 +57,7 @@ public class Rygel.MediaExport.HarvestingTask : Rygel.StateMachine,
 
     public HarvestingTask (RecursiveFileMonitor monitor,
                            File                 file,
-                           MediaContainer       parent,
-                           string?              flag = null) {
+                           MediaContainer       parent) {
         this.extractor = new MetadataExtractor ();
         this.origin = file;
         this.parent = parent;
@@ -71,7 +69,6 @@ public class Rygel.MediaExport.HarvestingTask : Rygel.StateMachine,
         this.files = new LinkedList<FileQueueEntry> ();
         this.containers = new GLib.Queue<MediaContainer> ();
         this.monitor = monitor;
-        this.flag = flag;
     }
 
     public void cancel () {
@@ -276,13 +273,6 @@ public class Rygel.MediaExport.HarvestingTask : Rygel.StateMachine,
             this.enumerate_directory.begin ();
         } else {
             // nothing to do
-            if (this.flag != null) {
-                try {
-                    this.cache.flag_object (this.origin,
-                                            this.flag);
-                } catch (Error error) {};
-            }
-
             this.completed ();
         }
 
diff --git a/src/plugins/media-export/rygel-media-export-media-cache-upgrader.vala 
b/src/plugins/media-export/rygel-media-export-media-cache-upgrader.vala
index 9e8b133..67c8730 100644
--- a/src/plugins/media-export/rygel-media-export-media-cache-upgrader.vala
+++ b/src/plugins/media-export/rygel-media-export-media-cache-upgrader.vala
@@ -420,6 +420,45 @@ internal class Rygel.MediaExport.MediaCacheUpgrader {
     private void update_v12_v13 () {
         try {
             this.database.begin ();
+            this.database.exec ("CREATE TEMPORARY TABLE object_backup(parent TEXT CONSTRAINT parent_fk_id " +
+                                "REFERENCES Object(upnp_id), " +
+                                "upnp_id TEXT PRIMARY KEY, " +
+                                "type_fk INTEGER, " +
+                                "title TEXT NOT NULL, " +
+                                "timestamp INTEGER NOT NULL, " +
+                                "uri TEXT, " +
+                                "object_update_id INTEGER, " +
+                                "deleted_child_count INTEGER, " +
+                                "container_update_id INTEGER)");
+            this.database.exec ("INSERT INTO object_backup SELECT " +
+                                "parent, upnp_id, type_fk, title, " +
+                                "timestamp, uri, object_update_id, " +
+                                "deleted_child_count, container_update_id " +
+                                "FROM object");
+            this.database.exec ("DROP TRIGGER IF EXISTS trgr_update_closure");
+            this.database.exec ("DROP TRIGGER IF EXISTS trgr_delete_closure");
+            this.database.exec ("DROP TRIGGER IF EXISTS trgr_delete_metadata");
+            this.database.exec ("DROP INDEX IF EXISTS idx_parent");
+            this.database.exec ("DROP INDEX IF EXISTS idx_object_upnp_id");
+            this.database.exec ("DROP INDEX IF EXISTS idx_uri");
+            this.database.exec ("DROP TABLE object");
+            this.database.exec ("CREATE TABLE object " +
+                                "(parent TEXT CONSTRAINT parent_fk_id " +
+                                "REFERENCES Object(upnp_id), " +
+                                "upnp_id TEXT PRIMARY KEY, " +
+                                "type_fk INTEGER, " +
+                                "title TEXT NOT NULL, " +
+                                "timestamp INTEGER NOT NULL, " +
+                                "uri TEXT, " +
+                                "object_update_id INTEGER, " +
+                                "deleted_child_count INTEGER, " +
+                                "container_update_id INTEGER)");
+            this.database.exec ("INSERT INTO object SELECT parent, " +
+                                "upnp_id, type_fk, title, timestamp, " +
+                                "uri, object_update_id, " +
+                                "deleted_child_count, container_update_id " +
+                                "FROM object_backup");
+            this.database.exec ("DROP TABLE object_backup");
             this.database.exec ("ALTER TABLE object " +
                                 "ADD COLUMN is_guarded INTEGER");
             /* This intentionally sets all rows in is_guarded column
@@ -427,14 +466,17 @@ internal class Rygel.MediaExport.MediaCacheUpgrader {
              */
             this.database.exec ("UPDATE object SET is_guarded = 0");
             this.database.exec ("UPDATE schema_info SET version = '13'");
+            this.database.exec (this.sql.make (SQLString.TRIGGER_COMMON));
+            this.database.exec (this.sql.make (SQLString.TRIGGER_CLOSURE));
+            this.database.exec (this.sql.make (SQLString.INDEX_COMMON));
 
-            database.commit ();
-            database.exec ("VACUUM");
-            database.analyze ();
+            this.database.commit ();
+            this.database.exec ("VACUUM");
+            this.database.analyze ();
         } catch (DatabaseError error) {
-            database.rollback ();
+            this.database.rollback ();
             warning ("Database upgrade failed: %s", error.message);
-            database = null;
+            this.database = null;
         }
     }
 }
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 79bdce3..92da986 100644
--- a/src/plugins/media-export/rygel-media-export-media-cache.vala
+++ b/src/plugins/media-export/rygel-media-export-media-cache.vala
@@ -469,25 +469,6 @@ public class Rygel.MediaExport.MediaCache : Object {
                                                     max_objects);
     }
 
-    public void flag_object (File file, string flag) throws Error {
-        GLib.Value[] args = { flag, file.get_uri () };
-        this.db.exec ("UPDATE Object SET flags = ? WHERE uri = ?", args);
-    }
-
-    public Gee.List<string> get_flagged_uris (string flag) throws Error {
-        var uris = new ArrayList<string> ();
-        const string query = "SELECT uri FROM object WHERE flags = ?";
-
-        GLib.Value[] args = { flag };
-
-        var cursor = this.db.exec_cursor (query, args);
-        foreach (var statement in cursor) {
-            uris.add (statement.column_text (0));
-        }
-
-        return uris;
-    }
-
     public string get_reset_token () {
         try {
             var cursor = this.exec_cursor (SQLString.RESET_TOKEN);
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 a5215ca..8bc8fff 100644
--- a/src/plugins/media-export/rygel-media-export-sql-factory.vala
+++ b/src/plugins/media-export/rygel-media-export-sql-factory.vala
@@ -215,7 +215,6 @@ internal class Rygel.MediaExport.SQLFactory : Object {
                           "title TEXT NOT NULL, " +
                           "timestamp INTEGER NOT NULL, " +
                           "uri TEXT, " +
-                          "flags TEXT, " +
                           "object_update_id INTEGER, " +
                           "deleted_child_count INTEGER, " +
                           "container_update_id INTEGER, " +


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]