Skip to content

Commit

Permalink
Merge pull request #28831 from owncloud/webui-upload-timeouthandling
Browse files Browse the repository at this point in the history
Better timeout detection in web UI uploads + chunked uploads
  • Loading branch information
Vincent Petry authored Sep 4, 2017
2 parents bcde380 + 5bda4ee commit a15b8dc
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion apps/files/js/file-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@ OC.FileUpload.prototype = {
}
this.data.headers['requesttoken'] = OC.requestToken;

// prevent global error handler to kick in on timeout
this.data.allowAuthErrors = true;

var chunkFolderPromise;
if ($.support.blobSlice
&& this.uploader.fileUploadParam.maxChunkSize
Expand Down Expand Up @@ -340,6 +343,13 @@ OC.FileUpload.prototype = {
getResponse: function() {
var response = this.data.response();
if (response.errorThrown) {
if (response.errorThrown === 'timeout') {
return {
status: 0,
message: t('core', 'Upload timeout for file "{file}"', {file: this.getFileName()})
};
}

// attempt parsing Sabre exception is available
var xml = response.jqXHR.responseXML;
if (xml.documentElement.localName === 'error' && xml.documentElement.namespaceURI === 'DAV:') {
Expand All @@ -362,8 +372,20 @@ OC.FileUpload.prototype = {
// likely due to internal server error
response = {status: 500};
}
} else {
} else if (response.result) {
response = response.result;
} else {
if (response.jqXHR.status === 0 && response.jqXHR.statusText === 'error') {
// timeout (IE11)
return {
status: 0,
message: t('core', 'Upload timeout for file "{file}"', {file: this.getFileName()})
};
}
return {
status: response.jqXHR.status,
message: t('core', 'Unknown error "{error}" uploading file "{file}"', {error: response.jqXHR.statusText, file: this.getFileName()})
};
}
return response;
},
Expand Down

0 comments on commit a15b8dc

Please sign in to comment.