[gnome-shell-extensions] places-menu: don't crash if a special directory or mount doesn't exists



commit 6c1dbe1ee1b1e0917479f32b4e84b75b2c7f7b60
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Mon Oct 22 21:40:30 2012 +0200

    places-menu: don't crash if a special directory or mount doesn't exists
    
    Under broken configurations, it is possible that a special directory
    is configured but does not exist. In that case, just skip the menu item
    altogheter.

 extensions/places-menu/placeDisplay.js |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/extensions/places-menu/placeDisplay.js b/extensions/places-menu/placeDisplay.js
index 8984d06..433f32b 100644
--- a/extensions/places-menu/placeDisplay.js
+++ b/extensions/places-menu/placeDisplay.js
@@ -123,8 +123,15 @@ const PlacesManager = new Lang.Class({
             let specialPath = GLib.get_user_special_dir(DEFAULT_DIRECTORIES[i]);
             if (specialPath == homePath)
                 continue;
-            this._places.special.push(new PlaceInfo('special',
-                                                    Gio.File.new_for_path(specialPath)));
+
+            let file = Gio.File.new_for_path(specialPath), info;
+            try {
+                info = new PlaceInfo('special', file);
+            } catch(e if e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.NOT_FOUND)) {
+                continue;
+            }
+
+            this._places.special.push(info);
         }
 
         /*
@@ -293,7 +300,14 @@ const PlacesManager = new Lang.Class({
     },
 
     _addMount: function(kind, mount) {
-        let devItem = new PlaceDeviceInfo(kind, mount);
+        let devItem;
+
+        try {
+            devItem = new PlaceDeviceInfo(kind, mount);
+        } catch(e if e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.NOT_FOUND)) {
+            return;
+        }
+
         this._places[kind].push(devItem);
     },
 



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