From 1cc726593eb3bce60d6ca41488d9a80ce96fc599 Mon Sep 17 00:00:00 2001 From: Rui Matos Date: Mon, 18 Mar 2013 15:53:11 +0100 Subject: [PATCH] runDialog: Ignore expected IO errors while enumerating $PATH $PATH might contain non-existent or non-directory entries. Ignore those error cases. https://bugzilla.gnome.org/show_bug.cgi?id=696064 --- js/ui/runDialog.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/js/ui/runDialog.js b/js/ui/runDialog.js index bedea40f8..9d288d92a 100644 --- a/js/ui/runDialog.js +++ b/js/ui/runDialog.js @@ -161,16 +161,22 @@ const RunDialog = new Lang.Class({ let paths = GLib.getenv('PATH').split(':'); paths.push(GLib.get_home_dir()); let someResults = paths.map(function(path) { - let file = Gio.File.new_for_path(path); - let fileEnum = file.enumerate_children('standard::name', Gio.FileQueryInfoFlags.NONE, null); - let info; let results = []; - while ((info = fileEnum.next_file(null))) { - let name = info.get_name(); - if (name.slice(0, text.length) == text) - results.push(name); + try { + let file = Gio.File.new_for_path(path); + let fileEnum = file.enumerate_children('standard::name', Gio.FileQueryInfoFlags.NONE, null); + let info; + while ((info = fileEnum.next_file(null))) { + let name = info.get_name(); + if (name.slice(0, text.length) == text) + results.push(name); + } + } catch (e if (!e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.NOT_FOUND) && + !e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.NOT_DIRECTORY))) { + log(e); + } finally { + return results; } - return results; }); let results = someResults.reduce(function(a, b) { return a.concat(b);