don't get ourselves banned by repeatedly polling an expired download
This commit is contained in:
parent
4276189595
commit
6ef96a9dc5
|
@ -6,7 +6,14 @@ document.addEventListener("DOMContentLoaded", () => {
|
|||
|
||||
updateInterval = setInterval(() => {
|
||||
fetch(`info?code=${CODE}`)
|
||||
.then((res) => res.json())
|
||||
.then((res) => {
|
||||
if (res.status === 404) {
|
||||
clearInterval(updateInterval);
|
||||
return Promise.reject("Download not found");
|
||||
} else {
|
||||
return res.json();
|
||||
}
|
||||
})
|
||||
.then((info) => {
|
||||
for (const [index, offset] of info.offsets.entries()) {
|
||||
table.children[index].className = (offset > info.available) ? "unavailable" : "";
|
||||
|
@ -14,6 +21,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
|||
if (info.available === info.file.size) {
|
||||
clearInterval(updateInterval);
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch(console.error);
|
||||
}, 5000);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue