From ed12c9d611ce46d82b78b90c7e2e9b237d2e8ec2 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Wed, 5 Dec 2012 19:28:50 -0500 Subject: [PATCH] fileUtils: Don't fail if we can't find an error We need to make sure that we decrement the number of dirs that we've loaded, and call the callback on error. https://bugzilla.gnome.org/show_bug.cgi?id=689749 --- js/misc/fileUtils.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/js/misc/fileUtils.js b/js/misc/fileUtils.js index f130b2bbd..af6b378b2 100644 --- a/js/misc/fileUtils.js +++ b/js/misc/fileUtils.js @@ -26,6 +26,13 @@ function listDirAsync(file, callback) { } function _collectFromDirectoryAsync(dir, loadState) { + function done() { + loadState.numLoading--; + if (loadState.loadedCallback && + loadState.numLoading == 0) + loadState.loadedCallback(loadState.data); + } + dir.query_info_async('standard:type', Gio.FileQueryInfoFlags.NONE, GLib.PRIORITY_DEFAULT, null, function(object, res) { try { @@ -33,18 +40,15 @@ function _collectFromDirectoryAsync(dir, loadState) { } catch (e) { if (!e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.NOT_FOUND)) log(e.message); + done(); return; } - loadState.numLoading++; listDirAsync(dir, Lang.bind(this, function(infos) { for (let i = 0; i < infos.length; i++) loadState.processFile(dir.get_child(infos[i].get_name()), infos[i], loadState.data); - loadState.numLoading--; - if (loadState.loadedCallback && - loadState.numLoading == 0) - loadState.loadedCallback(loadState.data); + done(); })); }); } @@ -68,6 +72,7 @@ function collectFromDatadirsAsync(subdir, params) { let dataDirs = GLib.get_system_data_dirs(); if (params.includeUserDir) dataDirs.unshift(GLib.get_user_data_dir()); + loadState.numLoading = dataDirs.length; for (let i = 0; i < dataDirs.length; i++) { let path = GLib.build_filenamev([dataDirs[i], 'gnome-shell', subdir]);