[assist] Fix deep loading of S3 paths that has folders on subsequent pages
@@ -134,14 +134,21 @@ var AssistS3Entry = (function () {
return;
}
- var findNextAndLoadDeep = function () {
var nextName = folders.shift();
+ var findNextAndLoadDeep = function () {
var foundEntry = $.grep(self.entries(), function (entry) {
return entry.definition.name === nextName && entry.definition.type === 'dir';
});
+
if (foundEntry.length === 1) {
foundEntry[0].loadDeep(folders, callback);
- } else if (! self.hasErrors()) {
+ } else if (self.hasMorePages) {
+ self.fetchMore(function () {
+ findNextAndLoadDeep();
+ }, function () {
+ callback(self);
+ });
+ } else {
callback(self);
}
};
@@ -180,7 +187,7 @@ var AssistS3Entry = (function () {
}
};
- AssistS3Entry.prototype.fetchMore = function () {
+ AssistS3Entry.prototype.fetchMore = function (successCallback, errorCallback) {
var self = this;
if (!self.hasMorePages || self.loadingMore()) {
return;
@@ -206,9 +213,15 @@ var AssistS3Entry = (function () {
})
})));
self.loadingMore(false);
+ if (successCallback) {
+ successCallback();
+ }
},
errorCallback: function () {
self.hasErrors(true);
+ if (errorCallback) {
+ errorCallback();
+ }
}
});
};
