aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/js/file-upload.js
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files/js/file-upload.js')
-rw-r--r--apps/files/js/file-upload.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js
index 1b85f578f43..75d9d0ebdfc 100644
--- a/apps/files/js/file-upload.js
+++ b/apps/files/js/file-upload.js
@@ -961,6 +961,7 @@ OC.Uploader.prototype = _.extend({
var bufferSize = 20;
var buffer = [];
var bufferIndex = 0;
+ var bufferIndex2 = 0;
var bufferTotal = 0;
for(var i = 0; i < bufferSize;i++){
buffer[i] = 0;
@@ -1006,8 +1007,17 @@ OC.Uploader.prototype = _.extend({
bufferTotal = bufferTotal - (buffer[bufferIndex]) + remainingSeconds;
buffer[bufferIndex] = remainingSeconds; //buffer to make it smoother
bufferIndex = (bufferIndex + 1) % bufferSize;
+ bufferIndex2++;
}
- var smoothRemainingSeconds = (bufferTotal / bufferSize); //seconds
+ var smoothRemainingSeconds;
+ if (bufferIndex2 > 0 && bufferIndex2 < 20) {
+ smoothRemainingSeconds = bufferTotal / bufferIndex2;
+ } else if (bufferSize > 0) {
+ smoothRemainingSeconds = bufferTotal / bufferSize;
+ } else {
+ smoothRemainingSeconds = 1;
+ }
+
var h = moment.duration(smoothRemainingSeconds, "seconds").humanize();
$('#uploadprogressbar .label .mobile').text(h);
$('#uploadprogressbar .label .desktop').text(h);