Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions dist/flow.js

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

2 changes: 1 addition & 1 deletion dist/flow.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/FlowChunk.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,11 +444,11 @@ export default class FlowChunk {
status(isTest) {
if (this.readState === 1) {
return 'reading';
} else if (this.pendingRetry || this.preprocessState === 1) {
} else if (this.preprocessState === 1) {
// if pending retry then that's effectively the same as actively uploading,
// there might just be a slight delay before the retry starts
return 'uploading';
} else if (!this.xhr) {
} else if (!this.xhr || this.pendingRetry) {
return 'pending';
} else if (this.xhr.readyState < 4) {
// Status is really 'OPENED', 'HEADERS_RECEIVED'
Expand Down
6 changes: 3 additions & 3 deletions src/FlowFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,16 +196,16 @@ export default class FlowFile {
abort(reset) {
this.currentSpeed = 0;
this.averageSpeed = 0;
var chunks = this.chunks;
if (reset) {
this.chunks = [];
}
each(chunks, function (c) {
for (let c of this.chunks) {
if (c.status() === 'uploading') {
c.abort();
c.pendingRetry = true;
this.flowObj.uploadNextChunk();
}
}, this);
}
}

/**
Expand Down
4 changes: 3 additions & 1 deletion test/uploadSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ describe('upload file', function() {
it('should pause and resume file', function () {
flow.opts.chunkSize = 1;
flow.opts.simultaneousUploads = 2;
flow.opts.testChunks = false;
flow.addFile(new Blob(['1234']));
flow.addFile(new Blob(['56']));
var files = flow.files;
Expand Down Expand Up @@ -271,14 +272,15 @@ describe('upload file', function() {
flow.addFile(new Blob(['12']));
var file = flow.files[0];
flow.upload();
expect(file.chunks[0].status()).toBe('uploading');
expect(xhr.requests.length).toBe(1);

xhr.requests[0].respond(400);
expect(xhr.requests.length).toBe(1);
expect(error).not.toHaveBeenCalled();
expect(success).not.toHaveBeenCalled();
expect(retry).toHaveBeenCalled();
expect(file.chunks[0].status()).toBe('uploading');
expect(file.chunks[0].status()).toBe('pending');

jasmine.clock().tick(100);
expect(xhr.requests.length).toBe(2);
Expand Down