Skip to content

Commit

Permalink
Merge pull request #822 from pierotofy/progressfix
Browse files Browse the repository at this point in the history
Fixed delta calculations in progress upload
  • Loading branch information
pierotofy authored Feb 19, 2020
2 parents 047a8de + d0b64db commit 083690e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions app/static/app/js/components/ProjectListItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,18 +141,22 @@ 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({
progress,
totalBytesSent,
lastUpdated: now
});

file.deltaBytesSent = bytesSent;
}
})
.on("complete", (file) => {
Expand Down

0 comments on commit 083690e

Please sign in to comment.