Check the blob size instead of the progress reports (#3249)

This commit is contained in:
Phillip Schichtel
2024-02-29 17:33:26 +01:00
committed by GitHub
parent 9274ee72ad
commit 0df9487527

View File

@@ -78,7 +78,6 @@ export const download = (
toastCallback: () => void,
) => {
let basename = document.baseURI.replace(window.location.origin, "");
let bytesLoaded = 0;
const state = store.getState();
const anonymousMode = state.system.anonymousMode;
@@ -107,7 +106,6 @@ export const download = (
"progress",
function (evt) {
let percentComplete = Math.round((evt.loaded / fileSize) * 100);
bytesLoaded = evt.loaded;
if (progressCallback) {
progressCallback(percentComplete);
}
@@ -118,7 +116,7 @@ export const download = (
req.responseType = "blob";
req.onreadystatechange = () => {
if (req.readyState === XMLHttpRequest.DONE) {
let completeDownload = bytesLoaded === fileSize;
let completeDownload = req.response.size === fileSize;
if (req.status === StatusCodes.OK && completeDownload) {
const rspHeader = req.getResponseHeader("Content-Disposition");