]> source.dussan.org Git - nextcloud-server.git/commitdiff
file-upload.js modified : Remaining upload time corrected
authorSarthikaDhawan <sarthika15170@iiitd.ac.in>
Mon, 6 Mar 2017 11:08:35 +0000 (16:38 +0530)
committerRoeland Jago Douma <roeland@famdouma.nl>
Tue, 4 Apr 2017 06:51:20 +0000 (08:51 +0200)
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
apps/files/js/file-upload.js [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index ad4d03a..c7e2329
@@ -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,16 @@ OC.Uploader.prototype = _.extend({
                                                bufferTotal = bufferTotal - (buffer[bufferIndex]) + remainingSeconds;
                                                buffer[bufferIndex] = remainingSeconds; //buffer to make it smoother
                                                bufferIndex = (bufferIndex + 1) % bufferSize;
+                                               bufferIndex2 = bufferIndex2++;
                                        }
-                                       var smoothRemainingSeconds = (bufferTotal / bufferSize); //seconds
+                                       var smoothRemainingSeconds;
+                                       if(bufferIndex2<20) {
+                                                       smoothRemainingSeconds = bufferTotal / bufferIndex2;
+                                       }
+                                       else {
+                                                smoothRemainingSeconds = bufferTotal / bufferSize; 
+                                       }
+
                                        var h = moment.duration(smoothRemainingSeconds, "seconds").humanize();
                                        $('#uploadprogressbar .label .mobile').text(h);
                                        $('#uploadprogressbar .label .desktop').text(h);