Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable10] Better timeout detection in web UI uploads + chunked uploads #28896

Merged
merged 2 commits into from
Sep 4, 2017
Merged
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
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