From 6c1dbe1ee1b1e0917479f32b4e84b75b2c7f7b60 Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Mon, 22 Oct 2012 21:40:30 +0200 Subject: [PATCH] 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 file changed, 17 insertions(+), 3 deletions(-) diff --git a/extensions/places-menu/placeDisplay.js b/extensions/places-menu/placeDisplay.js index 8984d068..433f32b0 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); },