From 303cf3f8f8725aaf712a796cb68b4d0694c2ea95 Mon Sep 17 00:00:00 2001 From: Wim Brand Date: Tue, 21 Jan 2020 17:13:18 +0100 Subject: [PATCH] fix retry logic --- res/include/script/dependencies/UploadManager.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/res/include/script/dependencies/UploadManager.js b/res/include/script/dependencies/UploadManager.js index f7d03b5..7e45758 100644 --- a/res/include/script/dependencies/UploadManager.js +++ b/res/include/script/dependencies/UploadManager.js @@ -134,6 +134,9 @@ class UploadManager { if (typeof(job.onFinished) === "function") { job.onFinished(resp.id); } + + // Finish the upload job + um.finishUpload(); } else if (xhr.status >= 400) { // Request failed console.log("Upload error. status: " + xhr.status + " response: " + xhr.response); @@ -144,6 +147,9 @@ class UploadManager { job.tries++; um.uploadQueue.push(job); } + + // Sleep the upload thread for 5 seconds + window.setTimeout(() => { um.finishUpload(); }, 5000); } else { // Request did not arrive if (job.tries === 3) { // Upload failed @@ -154,10 +160,10 @@ class UploadManager { job.tries++; um.uploadQueue.push(job); } - } - // Finish the upload job - um.finishUpload(); + // Sleep the upload thread for 5 seconds + window.setTimeout(() => { um.finishUpload(); }, 5000); + } }; xhr.send(form); }