Merge pull request #3896 from nextcloud/xx621998xx-newbranch

Fix remaining upload time calculation
This commit is contained in:
Roeland Jago Douma 2017-04-04 10:24:32 +02:00 committed by GitHub
commit c0972a26ed
1 changed files with 11 additions and 1 deletions

View File

@ -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);