[rygel] media-export: Minor optimization



commit b9bd82688905bf76896f1aff6e1672a145bcdc61
Author: Jens Georg <mail jensge org>
Date:   Mon Aug 2 22:19:10 2010 +0300

    media-export: Minor optimization
    
    No need for generic API

 .../rygel-media-export-harvesting-task.vala        |    5 ++---
 .../rygel-media-export-media-cache.vala            |   10 +++++-----
 .../rygel-media-export-sql-factory.vala            |    2 +-
 3 files changed, 8 insertions(+), 9 deletions(-)
---
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 9d28dcb..c0f1da7 100644
--- a/src/plugins/media-export/rygel-media-export-harvesting-task.vala
+++ b/src/plugins/media-export/rygel-media-export-harvesting-task.vala
@@ -125,11 +125,10 @@ public class Rygel.MediaExport.HarvestingTask : Rygel.StateMachine, GLib.Object
      */
     private bool push_if_changed_or_unknown (File       file,
                                              FileInfo   info) {
-        var id = MediaCache.get_id (file);
         int64 timestamp;
         int64 size;
         try {
-            if (this.cache.exists (id, out timestamp, out size)) {
+            if (this.cache.exists (file, out timestamp, out size)) {
                 int64 mtime = (int64) info.get_attribute_uint64 (
                                         FILE_ATTRIBUTE_TIME_MODIFIED);
 
@@ -254,7 +253,7 @@ public class Rygel.MediaExport.HarvestingTask : Rygel.StateMachine, GLib.Object
             // nothing to do
             if (this.flag != null) {
                 try {
-                    this.cache.flag_object (MediaCache.get_id (this.origin),
+                    this.cache.flag_object (this.origin,
                                             this.flag);
                 } catch (Error error) {};
             }
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 54c427a..270cf77 100644
--- a/src/plugins/media-export/rygel-media-export-media-cache.vala
+++ b/src/plugins/media-export/rygel-media-export-media-cache.vala
@@ -153,11 +153,11 @@ public class Rygel.MediaExport.MediaCache : Object {
         return count;
     }
 
-    public bool exists (string    object_id,
+    public bool exists (File      file,
                         out int64 timestamp,
                         out int64 size) throws DatabaseError {
         bool exists = false;
-        GLib.Value[] values = { object_id };
+        GLib.Value[] values = { file.get_uri () };
         int64 tmp_timestamp = 0;
         int64 tmp_size = 0;
 
@@ -783,9 +783,9 @@ public class Rygel.MediaExport.MediaCache : Object {
                                                     max_objects);
     }
 
-    public void flag_object (string id, string flag) throws Error {
-        GLib.Value[] args = { flag, id };
-        this.db.exec ("UPDATE Object SET flags = ? WHERE upnp_id = ?", args);
+    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 {
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 06c387f..1cc7a91 100644
--- a/src/plugins/media-export/rygel-media-export-sql-factory.vala
+++ b/src/plugins/media-export/rygel-media-export-sql-factory.vala
@@ -145,7 +145,7 @@ internal class Rygel.MediaExport.SQLFactory : Object {
     private const string OBJECT_EXISTS_STRING =
     "SELECT COUNT(upnp_id), timestamp, m.size FROM Object " +
         "JOIN meta_data m ON m.object_fk = upnp_id " +
-        "WHERE Object.upnp_id = ?";
+        "WHERE Object.uri = ?";
 
     private const string GET_CHILD_ID_STRING =
     "SELECT upnp_id FROM OBJECT WHERE parent = ?";



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