aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/js
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2017-06-16 14:11:55 +0200
committerGitHub <noreply@github.com>2017-06-16 14:11:55 +0200
commitcc0ff6f5e37e8cce585d35280db7de7534697b5a (patch)
tree94fa03209e7eb6b5edbff21866d3d7258df260ff /apps/files/js
parent698a7cb7f0d15d2eee1854d1e7412e618dcc059e (diff)
parent2a1681510bf89c6a7ebf8548ce8494aa8a89d559 (diff)
downloadnextcloud-server-cc0ff6f5e37e8cce585d35280db7de7534697b5a.tar.gz
nextcloud-server-cc0ff6f5e37e8cce585d35280db7de7534697b5a.zip
Merge pull request #5177 from Bekcpear/master
Fix upload remaining time
Diffstat (limited to 'apps/files/js')
-rw-r--r--apps/files/js/file-upload.js28
1 files changed, 15 insertions, 13 deletions
diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js
index 1c5758ca50b..2fa3122a008 100644
--- a/apps/files/js/file-upload.js
+++ b/apps/files/js/file-upload.js
@@ -956,16 +956,7 @@ OC.Uploader.prototype = _.extend({
if (this._supportAjaxUploadWithProgress()) {
//remaining time
- var lastUpdate = new Date().getMilliseconds();
- var lastSize = 0;
- var bufferSize = 20;
- var buffer = [];
- var bufferIndex = 0;
- var bufferIndex2 = 0;
- var bufferTotal = 0;
- for(var i = 0; i < bufferSize;i++){
- buffer[i] = 0;
- }
+ var lastUpdate, lastSize, bufferSize, buffer, bufferIndex, bufferIndex2, bufferTotal;
// add progress handlers
fileupload.on('fileuploadadd', function(e, data) {
@@ -986,6 +977,17 @@ OC.Uploader.prototype = _.extend({
+ '</span></em>');
$('#uploadprogressbar').tooltip({placement: 'bottom'});
self._showProgressBar();
+ // initial remaining time variables
+ lastUpdate = new Date().getTime();
+ lastSize = 0;
+ bufferSize = 20;
+ buffer = [];
+ bufferIndex = 0;
+ bufferIndex2 = 0;
+ bufferTotal = 0;
+ for(var i = 0; i < bufferSize; i++){
+ buffer[i] = 0;
+ }
self.trigger('start', e, data);
});
fileupload.on('fileuploadprogress', function(e, data) {
@@ -996,12 +998,12 @@ OC.Uploader.prototype = _.extend({
fileupload.on('fileuploadprogressall', function(e, data) {
self.log('progress handle fileuploadprogressall', e, data);
var progress = (data.loaded / data.total) * 100;
- var thisUpdate = new Date().getMilliseconds();
+ var thisUpdate = new Date().getTime();
var diffUpdate = (thisUpdate - lastUpdate)/1000; // eg. 2s
lastUpdate = thisUpdate;
var diffSize = data.loaded - lastSize;
lastSize = data.loaded;
- diffSize = diffSize / diffUpdate; // apply timing factor, eg. 1mb/2s = 0.5mb/s
+ diffSize = diffSize / diffUpdate; // apply timing factor, eg. 1MiB/2s = 0.5MiB/s, unit is byte per second
var remainingSeconds = ((data.total - data.loaded) / diffSize);
if(remainingSeconds >= 0) {
bufferTotal = bufferTotal - (buffer[bufferIndex]) + remainingSeconds;
@@ -1025,7 +1027,7 @@ OC.Uploader.prototype = _.extend({
t('files', '{loadedSize} of {totalSize} ({bitrate})' , {
loadedSize: humanFileSize(data.loaded),
totalSize: humanFileSize(data.total),
- bitrate: humanFileSize(data.bitrate) + '/s'
+ bitrate: humanFileSize(data.bitrate / 8) + '/s'
})
);
$('#uploadprogressbar').progressbar('value', progress);