diff options
author | Johannes Zellner <johannes@cloudron.io> | 2019-02-24 20:44:24 +0100 |
---|---|---|
committer | Johannes Zellner <johannes@cloudron.io> | 2019-02-24 20:44:24 +0100 |
commit | 701c2be63f33a868f0369fe95d823ed0b11ec683 (patch) | |
tree | 16e165d36cb5d55726ce3bca1cd3e1fdb2211841 | |
parent | 7c15fe4c937c6f531f1d6e480977d36341eb1837 (diff) | |
download | Surfer-701c2be63f33a868f0369fe95d823ed0b11ec683.tar.gz Surfer-701c2be63f33a868f0369fe95d823ed0b11ec683.tar.zst Surfer-701c2be63f33a868f0369fe95d823ed0b11ec683.zip |
Ensure upload progress stays within bounds
-rw-r--r-- | frontend/js/app.js | 3 |
1 files changed, 2 insertions, 1 deletions
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) { | |||
171 | if (!(event.target instanceof XMLHttpRequestUpload)) return; | 171 | if (!(event.target instanceof XMLHttpRequestUpload)) return; |
172 | 172 | ||
173 | app.uploadStatus.done = finishedUploadSize + event.loaded; | 173 | app.uploadStatus.done = finishedUploadSize + event.loaded; |
174 | app.uploadStatus.percentDone = Math.round(app.uploadStatus.done / app.uploadStatus.size * 100); | 174 | var tmp = Math.round(app.uploadStatus.done / app.uploadStatus.size * 100); |
175 | app.uploadStatus.percentDone = tmp > 100 ? 100 : tmp; | ||
175 | }).end(function (error, result) { | 176 | }).end(function (error, result) { |
176 | if (result && result.statusCode === 401) return logout(); | 177 | if (result && result.statusCode === 401) return logout(); |
177 | if (result && result.statusCode !== 201) return callback('Error uploading file: ', result.statusCode); | 178 | if (result && result.statusCode !== 201) return callback('Error uploading file: ', result.statusCode); |