From: Johannes Zellner Date: Sun, 24 Feb 2019 19:44:24 +0000 (+0100) Subject: Ensure upload progress stays within bounds X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=701c2be63f33a868f0369fe95d823ed0b11ec683;p=perso%2FImmae%2FProjets%2FNodejs%2FSurfer.git Ensure upload progress stays within bounds --- diff --git a/frontend/js/app.js b/frontend/js/app.js index 7a80ba7..e446db3 100644 --- a/frontend/js/app.js +++ b/frontend/js/app.js @@ -171,7 +171,8 @@ function uploadFiles(files) { if (!(event.target instanceof XMLHttpRequestUpload)) return; app.uploadStatus.done = finishedUploadSize + event.loaded; - app.uploadStatus.percentDone = Math.round(app.uploadStatus.done / app.uploadStatus.size * 100); + var tmp = Math.round(app.uploadStatus.done / app.uploadStatus.size * 100); + app.uploadStatus.percentDone = tmp > 100 ? 100 : tmp; }).end(function (error, result) { if (result && result.statusCode === 401) return logout(); if (result && result.statusCode !== 201) return callback('Error uploading file: ', result.statusCode);