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
This commit is contained in:
parent
4153feeb15
commit
ed12c9d611
@ -26,6 +26,13 @@ function listDirAsync(file, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function _collectFromDirectoryAsync(dir, loadState) {
|
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,
|
dir.query_info_async('standard:type', Gio.FileQueryInfoFlags.NONE,
|
||||||
GLib.PRIORITY_DEFAULT, null, function(object, res) {
|
GLib.PRIORITY_DEFAULT, null, function(object, res) {
|
||||||
try {
|
try {
|
||||||
@ -33,18 +40,15 @@ function _collectFromDirectoryAsync(dir, loadState) {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (!e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.NOT_FOUND))
|
if (!e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.NOT_FOUND))
|
||||||
log(e.message);
|
log(e.message);
|
||||||
|
done();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
loadState.numLoading++;
|
|
||||||
listDirAsync(dir, Lang.bind(this, function(infos) {
|
listDirAsync(dir, Lang.bind(this, function(infos) {
|
||||||
for (let i = 0; i < infos.length; i++)
|
for (let i = 0; i < infos.length; i++)
|
||||||
loadState.processFile(dir.get_child(infos[i].get_name()),
|
loadState.processFile(dir.get_child(infos[i].get_name()),
|
||||||
infos[i], loadState.data);
|
infos[i], loadState.data);
|
||||||
loadState.numLoading--;
|
done();
|
||||||
if (loadState.loadedCallback &&
|
|
||||||
loadState.numLoading == 0)
|
|
||||||
loadState.loadedCallback(loadState.data);
|
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -68,6 +72,7 @@ function collectFromDatadirsAsync(subdir, params) {
|
|||||||
let dataDirs = GLib.get_system_data_dirs();
|
let dataDirs = GLib.get_system_data_dirs();
|
||||||
if (params.includeUserDir)
|
if (params.includeUserDir)
|
||||||
dataDirs.unshift(GLib.get_user_data_dir());
|
dataDirs.unshift(GLib.get_user_data_dir());
|
||||||
|
loadState.numLoading = dataDirs.length;
|
||||||
|
|
||||||
for (let i = 0; i < dataDirs.length; i++) {
|
for (let i = 0; i < dataDirs.length; i++) {
|
||||||
let path = GLib.build_filenamev([dataDirs[i], 'gnome-shell', subdir]);
|
let path = GLib.build_filenamev([dataDirs[i], 'gnome-shell', subdir]);
|
||||||
|
Loading…
Reference in New Issue
Block a user