Skip to content

Commit

Permalink
fix: Upload progress shows number of files to upload and current index
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <[email protected]>
  • Loading branch information
susnux committed Aug 19, 2023
1 parent 5516d49 commit 1df60c0
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion apps/files/css/merged.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/files/css/upload.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/files/css/upload.scss
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
}
#uploadprogressbar .ui-progressbar-value.ui-widget-header.ui-corner-left {
height: calc(100% + 2px);
top: -1px;
top: -2px;
left: -1px;
position: absolute;
overflow: hidden;
Expand Down
26 changes: 20 additions & 6 deletions apps/files/js/file-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -618,8 +618,10 @@ OC.Uploader.prototype = _.extend({
});
if (!self._uploading) {
self.totalToUpload = 0;
self.totalUploadCount = 0;
}
self.totalToUpload += _.reduce(uploads, function(memo, upload) { return memo+upload.getFile().size; }, 0);
self.totalUploadCount += uploads.length;
var semaphore = new OCA.Files.Semaphore(5);
var promises = _.map(uploads, function(upload) {
return semaphore.acquire().then(function(){
Expand Down Expand Up @@ -726,8 +728,9 @@ OC.Uploader.prototype = _.extend({
},

showUploadCancelMessage: _.debounce(function() {
OC.Notification.show(t('files', 'Upload cancelled.'), {timeout : 7, type: 'error'});
OC.Notification.show(t('files', 'Upload cancelled.'), { timeout : 7000, type: 'error' });
}, 500),

/**
* callback for the conflicts dialog
*/
Expand Down Expand Up @@ -1270,14 +1273,25 @@ OC.Uploader.prototype = _.extend({
smoothRemainingSeconds = bufferTotal / bufferSize;
}

if (bufferIndex % 4 === 0) {
// the number of currently running uploads
const runningUploads = Object.keys(self._uploads).length;

// Only show remaining time if enough buffer information is available and debounce to 1/4
if (bufferFilled && bufferIndex % 4 === 0) {
h = moment.duration(smoothRemainingSeconds, "seconds").humanize({m: 50, h: 50});
if (self.totalUploadCount > 1) {
h = t('files', '{remainingTime} ({currentNumber}/{total})', { remainingTime: h, currentNumber: self.totalUploadCount - runningUploads + 1, total: self.totalUploadCount });
}
}

// wait for the buffer to be at least half filled, approximately takes 3s
if (!(smoothRemainingSeconds >= 0 && smoothRemainingSeconds < 14400) || (bufferFilled == false && bufferIndex < bufferSize/2)) {
// show "Uploading ..." for durations longer than 4 hours
h = t('files', 'Uploading …');
// wait for the buffer to be filled and also show "Uploading ..." for durations longer than 4 hours
if (!bufferFilled || !(smoothRemainingSeconds >= 0 && smoothRemainingSeconds < 14400)) {
// Do not show file index when there is just one
if (self.totalUploadCount > 1) {
h = t('files', 'Uploading … ({currentNumber}/{total})', { currentNumber: self.totalUploadCount - runningUploads + 1, total: self.totalUploadCount });
} else {
h = t('files', 'Uploading …');
}
}

// smooth bitrate
Expand Down

0 comments on commit 1df60c0

Please sign in to comment.