downloads: handle multi-page results from Azure (#19138)

This commit is contained in:
Péter Szilágyi 2019-02-20 11:42:58 +02:00 committed by GitHub
parent 680f715585
commit 02c039f102
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 208 additions and 193 deletions

View File

@ -305,13 +305,37 @@
</script>
<script type="text/javascript">
// Create the blob retriever that iterates over all the pages of the blobstore.
var blobs = [];
var retrieveBlobs = function(marker, finished) {
// Generate the blob listing URL and request it from Azure
var url = 'https://gethstore.blob.core.windows.net/builds?restype=container&comp=list&maxresults=5000&prefix=geth-';
if (marker != "") {
url += "&marker=" + marker;
}
$.ajax({
url: 'https://gethstore.blob.core.windows.net/builds?restype=container&comp=list',
url: url,
type: 'GET',
error: function() {
alert("Failed to load releases!");
},
dataType: 'xml',
success: function(data) {
// List of blobs retrieved, acumulate them first of all
Array.prototype.push.apply(blobs, $(data).find('Blob'));
// If there are more pages, load them all
marker = $($(data).find('NextMarker')[0]).text();
if (marker != "") {
retrieveBlobs(marker, finished);
} else {
finished(blobs);
}
}
});
}
// Start retrieving the release blobs and populate the page on success
retrieveBlobs("", function() {
// Define the release tables
var releases = {
stable: [],
@ -321,7 +345,6 @@
var signatures = {};
// Iterate over all the blobs and populate the tables
var blobs = $(data).find('Blob')
for (var i = 0; i < blobs.length; i++) {
// Gather all available resources to later inspection
var name = $($(blobs[i]).find('Name')[0]).text();
@ -332,12 +355,6 @@
signatures[name] = true;
continue;
}
// Skip any blobs that do not start with "geth"
if (!name.startsWith("geth")) {
continue;
}
// Otherwise add an entry to one of the release tables
var parts = name.split("-");
var date = parts[parts.length-1].split(".")[0];
@ -521,8 +538,6 @@
}
// Mark the request done to possibly hide the loading page
requestDone();
},
type: 'GET'
});
</script>