From d0b64db08d05f6d6d539da95e40ef39141b1a550 Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Wed, 19 Feb 2020 11:00:25 -0500 Subject: [PATCH] Fixed delta calculations in progress upload --- app/static/app/js/components/ProjectListItem.jsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/static/app/js/components/ProjectListItem.jsx b/app/static/app/js/components/ProjectListItem.jsx index 716ba7f2..d33aacae 100644 --- a/app/static/app/js/components/ProjectListItem.jsx +++ b/app/static/app/js/components/ProjectListItem.jsx @@ -141,11 +141,13 @@ class ProjectListItem extends React.Component { .on("uploadprogress", (file, progress, bytesSent) => { const now = new Date().getTime(); - if (now - this.state.upload.lastUpdated > 500){ - file.deltaBytesSent = bytesSent - file.deltaBytesSent; - file.trackedBytesSent += file.deltaBytesSent; + if (bytesSent > file.size) bytesSent = file.size; + + if (progress === 100 || now - this.state.upload.lastUpdated > 500){ + const deltaBytesSent = bytesSent - file.deltaBytesSent; + file.trackedBytesSent += deltaBytesSent; - const totalBytesSent = this.state.upload.totalBytesSent + file.deltaBytesSent; + const totalBytesSent = this.state.upload.totalBytesSent + deltaBytesSent; const progress = totalBytesSent / this.state.upload.totalBytes * 100; this.setUploadState({ @@ -153,6 +155,8 @@ class ProjectListItem extends React.Component { totalBytesSent, lastUpdated: now }); + + file.deltaBytesSent = bytesSent; } }) .on("complete", (file) => {