diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2017-04-04 10:24:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-04 10:24:32 +0200 |
commit | c0972a26ed6737bcc9d0288f51c0371b98c81a61 (patch) | |
tree | 0ab1b7a92fbaab9c978465347e7599a087d8bf09 /apps/files/js/file-upload.js | |
parent | ec5377306d8824ab7f7e9e0f534c8fb9c2b81a65 (diff) | |
parent | b6c1f3fc6d36dbff40ce7791297765193cbd128c (diff) | |
download | nextcloud-server-c0972a26ed6737bcc9d0288f51c0371b98c81a61.tar.gz nextcloud-server-c0972a26ed6737bcc9d0288f51c0371b98c81a61.zip |
Merge pull request #3896 from nextcloud/xx621998xx-newbranch
Fix remaining upload time calculation
Diffstat (limited to 'apps/files/js/file-upload.js')
-rw-r--r-- | apps/files/js/file-upload.js | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js index ad4d03a1bdb..bfb88bc5d20 100644 --- a/apps/files/js/file-upload.js +++ b/apps/files/js/file-upload.js @@ -960,6 +960,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; @@ -1005,8 +1006,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); |