]> git.immae.eu Git - perso/Immae/Projets/Nodejs/Surfer.git/commitdiff
Ensure upload progress stays within bounds
authorJohannes Zellner <johannes@cloudron.io>
Sun, 24 Feb 2019 19:44:24 +0000 (20:44 +0100)
committerJohannes Zellner <johannes@cloudron.io>
Sun, 24 Feb 2019 19:44:24 +0000 (20:44 +0100)
frontend/js/app.js

index 7a80ba72d1849666da61d5038be3fc0fe947f565..e446db3dd374530f2309f1b8fe6c772e4ff2f70e 100644 (file)
@@ -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);