[rygel] media-export: Fix "unhandled error" warnings



commit 11938e8ae910713cc5ccaaa4c9cdade6d5519bd2
Author: Jens Georg <mail jensge org>
Date:   Tue Oct 13 13:41:54 2009 +0200

    media-export: Fix "unhandled error" warnings

 .../media-export/rygel-media-export-harvester.vala |   18 ++++++++++------
 .../rygel-media-export-root-container.vala         |   22 ++++++++++---------
 2 files changed, 23 insertions(+), 17 deletions(-)
---
diff --git a/src/plugins/media-export/rygel-media-export-harvester.vala b/src/plugins/media-export/rygel-media-export-harvester.vala
index 0362e92..b831bc4 100644
--- a/src/plugins/media-export/rygel-media-export-harvester.vala
+++ b/src/plugins/media-export/rygel-media-export-harvester.vala
@@ -113,17 +113,21 @@ public class Rygel.MediaExportHarvester : GLib.Object {
                                              out string id) {
         id = Checksum.compute_for_string (ChecksumType.MD5, file.get_uri ());
         int64 timestamp;
-        if (this.media_db.exists (id, out timestamp)) {
-            int64 mtime = (int64) info.get_attribute_uint64 (
+        try {
+            if (this.media_db.exists (id, out timestamp)) {
+                int64 mtime = (int64) info.get_attribute_uint64 (
                                                 FILE_ATTRIBUTE_TIME_MODIFIED);
 
-            if (mtime > timestamp) {
-                this.files.push_tail (new FileQueueEntry (file, true));
+                if (mtime > timestamp) {
+                    this.files.push_tail (new FileQueueEntry (file, true));
+                    return true;
+                }
+            } else {
+                this.files.push_tail (new FileQueueEntry (file, false));
                 return true;
             }
-        } else {
-            this.files.push_tail (new FileQueueEntry (file, false));
-            return true;
+        } catch (MediaDBError err) {
+            warning ("Failed to query database: %s", err.message);
         }
 
         return false;
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 7552564..c8ede44 100644
--- a/src/plugins/media-export/rygel-media-export-root-container.vala
+++ b/src/plugins/media-export/rygel-media-export-root-container.vala
@@ -150,23 +150,25 @@ public class Rygel.MediaExportRootContainer : Rygel.MediaDBContainer {
         this.monitor = new MediaExportRecursiveFileMonitor (null);
         this.monitor.changed.connect (this.on_file_changed);
 
-        this.service = new MediaExportDBusService (this);
+        try {
+            this.service = new MediaExportDBusService (this);
+        } catch (Error err) {
+            warning ("Failed to create MediaExport DBus service: %s",
+                     err.message);
+        }
         this.dynamic_elements = new MediaExportDynamicContainer (db, this);
 
-        int64 timestamp;
-        if (!this.media_db.exists ("0", out timestamp)) {
-            try {
+        try {
+            int64 timestamp;
+            if (!this.media_db.exists ("0", out timestamp)) {
                 media_db.save_object (this);
-            } catch (Error error) {
-                // do nothing
             }
-        }
 
-        if (!this.media_db.exists ("DynamicContainerId", out timestamp)) {
-            try {
+            if (!this.media_db.exists ("DynamicContainerId", out timestamp)) {
                 media_db.save_object (this.dynamic_elements);
-            } catch (Error error) {
             }
+        } catch (Error error) {
+            // do nothing
         }
 
         ArrayList<string> ids;



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