[rygel] media-export: Catch previously uncaught exceptions



commit 2561309649a49ba525af75246ba2849640758c62
Author: Jens Georg <mail jensge org>
Date:   Sat Mar 27 18:04:14 2010 +0100

    media-export: Catch previously uncaught exceptions

 .../rygel-media-export-root-container.vala         |   41 ++++++++++++-------
 1 files changed, 26 insertions(+), 15 deletions(-)
---
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 fcb465e..f1a264a 100644
--- a/src/plugins/media-export/rygel-media-export-root-container.vala
+++ b/src/plugins/media-export/rygel-media-export-root-container.vala
@@ -385,28 +385,39 @@ public class Rygel.MediaExportRootContainer : Rygel.MediaDBContainer {
                 var parent = file.get_parent ();
                 var id = Checksum.compute_for_string (ChecksumType.MD5,
                                                       parent.get_uri ());
-                var parent_container = this.media_db.get_object (id);
-                if (parent_container != null) {
-                    this.harvest (file, (MediaContainer)parent_container);
-                } else {
-                    assert_not_reached ();
+                try {
+                    var parent_container = this.media_db.get_object (id);
+                    if (parent_container != null) {
+                        this.harvest (file, (MediaContainer)parent_container);
+                    } else {
+                        assert_not_reached ();
+                    }
+                } catch (Rygel.DatabaseError error) {
+                    warning ("Error while getting parent container for " +
+                             "filesystem event: %s",
+                             error.message);
                 }
                 break;
             case FileMonitorEvent.DELETED:
                 var id = Checksum.compute_for_string (ChecksumType.MD5,
                                                       file.get_uri ());
 
-                // the full object is fetched instead of simply calling exists
-                // because we need the parent to signalize the change
-                var obj = this.media_db.get_object (id);
-
-                // it may be that files removed are files that are not
-                // in the database, because they're not media files
-                if (obj != null) {
-                    this.media_db.remove_object (obj);
-                    if (obj.parent != null) {
-                        obj.parent.updated ();
+                try {
+                    // the full object is fetched instead of simply calling exists
+                    // because we need the parent to signalize the change
+                    var obj = this.media_db.get_object (id);
+
+                    // it may be that files removed are files that are not
+                    // in the database, because they're not media files
+                    if (obj != null) {
+                        this.media_db.remove_object (obj);
+                        if (obj.parent != null) {
+                            obj.parent.updated ();
+                        }
                     }
+                } catch (Error error) {
+                    warning ("Error removing object from database: %s",
+                             error.message);
                 }
                 break;
             default:



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