Skip to content
This repository has been archived by the owner on Nov 20, 2018. It is now read-only.

Commit

Permalink
fix(concurrent chunking): account for cancelled chunk uploads that ar…
Browse files Browse the repository at this point in the history
…e still waiting for signature

This should prevent a chunk upload that has not yet called xhr.send() from starting if it has been cancelled by error handling code.
#1519
  • Loading branch information
rnicholus committed Feb 17, 2016
1 parent 540aa7d commit bc22159
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![Fine Uploader](http://fineuploader.com/img/FineUploader_logo.png)](http://fineuploader.com/)

Version: 5.5.1-2
Version: 5.5.1-3

[![Build Status](https://travis-ci.org/FineUploader/fine-uploader.png?branch=master)](https://travis-ci.org/FineUploader/fine-uploader) | [![Semver badge](http://calm-shore-6115.herokuapp.com/?label=SemVer&value=2.0.0&color=green)](http://semver.org/spec/v2.0.0.html)

Expand Down
22 changes: 14 additions & 8 deletions client/js/s3/s3.xhr.upload.handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,22 @@ qq.s3.XhrUploadHandler = function(spec, proxy) {
// Add appropriate headers to the multipart upload request.
// Once these have been determined (asynchronously) attach the headers and send the chunk.
chunked.initHeaders(id, chunkIdx, chunkData.blob).then(function(headers, endOfUrl) {
var url = domain + "/" + endOfUrl;
handler._registerProgressHandler(id, chunkIdx, chunkData.size);
upload.track(id, xhr, chunkIdx).then(promise.success, promise.failure);
xhr.open("PUT", url, true);
if (xhr._cancelled) {
log(qq.format("Upload of item {}.{} cancelled. Upload will not start after successful signature request.", id, chunkIdx));
promise.failure({error: "Chunk upload cancelled"});
}
else {
var url = domain + "/" + endOfUrl;
handler._registerProgressHandler(id, chunkIdx, chunkData.size);
upload.track(id, xhr, chunkIdx).then(promise.success, promise.failure);
xhr.open("PUT", url, true);

qq.each(headers, function(name, val) {
xhr.setRequestHeader(name, val);
});
qq.each(headers, function(name, val) {
xhr.setRequestHeader(name, val);
});

xhr.send(chunkData.blob);
xhr.send(chunkData.blob);
}
}, function() {
promise.failure({error: "Problem signing the chunk!"}, xhr);
});
Expand Down
3 changes: 3 additions & 0 deletions client/js/upload-handler/upload.handler.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ qq.UploadHandlerController = function(o, namespace) {
qq.each(handler._getXhrs(id), function(ckid, ckXhr) {
log(qq.format("Attempting to abort file {}.{}. XHR readyState {}. ", id, ckid, ckXhr.readyState));
ckXhr.abort();
// Flag the transport, in case we are waiting for some other async operation
// to complete before attempting to upload the chunk
ckXhr._cancelled = true;
});

// We must indicate that all aborted chunks are no longer in progress
Expand Down
2 changes: 1 addition & 1 deletion client/js/version.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/*global qq */
qq.version = "5.5.1-2";
qq.version = "5.5.1-3";
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "fine-uploader",
"title": "Fine Uploader",
"version": "5.5.1-2",
"version": "5.5.1-3",
"description": "Multiple file upload component with progress-bar, drag-and-drop, support for all modern browsers.",
"main": "./fine-uploader/js/fineuploader.js",
"directories": {
Expand Down

0 comments on commit bc22159

Please sign in to comment.