ImportHandler: UI for showing maxFileSize error on import

This commit is an integration to f4418149cb.
pull/3865/head
John McLear 2020-04-14 10:02:21 +00:00
parent 53d8e32ecb
commit c6cb253f76
3 changed files with 11 additions and 2 deletions

View File

@ -143,5 +143,6 @@
"pad.impexp.uploadFailed": "The upload failed, please try again",
"pad.impexp.importfailed": "Import failed",
"pad.impexp.copypaste": "Please copy paste",
"pad.impexp.exportdisabled": "Exporting as {{type}} format is disabled. Please contact your system administrator for details."
"pad.impexp.exportdisabled": "Exporting as {{type}} format is disabled. Please contact your system administrator for details.",
"pad.impexp.maxFileSize": "File too big. Contact your site administrator to increase the allowed file size for import"
}

View File

@ -82,6 +82,12 @@ async function doImport(req, res, padId)
if (err) {
console.warn("Uploading Error: " + err.stack);
}
// I hate doing indexOf here but I can't see anything to use...
if (err.stack.indexOf("maxFileSize") !== -1) {
reject("maxFileSize");
}
reject("uploadFailed");
}
if(!files.file){ // might not be a graceful fix but it works
@ -261,7 +267,7 @@ exports.doImport = function (req, res, padId)
let status = "ok";
doImport(req, res, padId).catch(err => {
// check for known errors and replace the status
if (err == "uploadFailed" || err == "convertFailed" || err == "padHasData") {
if (err == "uploadFailed" || err == "convertFailed" || err == "padHasData" || err == "maxFileSize") {
status = err;
} else {
throw err;

View File

@ -111,6 +111,8 @@ var padimpexp = (function()
msg = html10n.get("pad.impexp.uploadFailed");
} else if(status === "padHasData"){
msg = html10n.get("pad.impexp.padHasData");
} else if(status === "maxFileSize"){
msg = html10n.get("pad.impexp.maxFileSize");
}
function showError(fade)