Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

recursively call readEntries #2502

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 13 additions & 3 deletions Kudu.Services.Web/Content/Scripts/FileBrowser.js
Expand Up @@ -830,15 +830,25 @@ $.connection.hub.start().done(function () {
deferred.resolveWith(null, [{ name: parentPath + '/' + entry.name, contents: file }]);
});
} else {
entry.createReader().readEntries(function (entries) {
var dirReader = entry.createReader();
var totalEntriesInDir = [];
var directoryCallback = function (entries) {
if (entries.length) {
totalEntriesInDir = totalEntriesInDir.concat(entries);
// keep reading
dirReader.readEntries(directoryCallback);
} else {
// finished reading, process totalEntriesInDir
var directoryPath = parentPath + '/' + entry.name;
whenArray($.map(entries, function (e) {
whenArray($.map(totalEntriesInDir, function (e) {
return _processEntry(e, directoryPath);
})).done(function () {
deferred.resolveWith(null, [Array.prototype.concat.apply([], arguments)]);
});;
});
}
}
dirReader.readEntries(directoryCallback);
}
return deferred.promise();
}

Expand Down