diff --git a/src/node/handler/ImportHandler.js b/src/node/handler/ImportHandler.js
index 5732beada..67bef01ce 100644
--- a/src/node/handler/ImportHandler.js
+++ b/src/node/handler/ImportHandler.js
@@ -258,21 +258,18 @@ const doImport = async (req, res, padId) => {
};
exports.doImport = async (req, res, padId) => {
- let status = 'ok';
+ let httpStatus = 200;
+ let code = 0;
+ let message = 'ok';
let directDatabaseAccess;
try {
directDatabaseAccess = await doImport(req, res, padId);
} catch (err) {
- if (!(err instanceof ImportError) || !err.status) throw err;
- status = err.status;
+ const known = err instanceof ImportError && err.status;
+ if (!known) logger.error(`Internal error during import: ${err.stack || err}`);
+ httpStatus = known ? 400 : 500;
+ code = known ? 1 : 2;
+ message = known ? err.status : 'internalError';
}
- // close the connection
- res.send([
- '',
- ].join('\n'));
+ res.status(httpStatus).json({code, message, data: {directDatabaseAccess}});
};
diff --git a/src/static/js/pad_impexp.js b/src/static/js/pad_impexp.js
index 07848d141..60a51354f 100644
--- a/src/static/js/pad_impexp.js
+++ b/src/static/js/pad_impexp.js
@@ -23,9 +23,9 @@
*/
const padimpexp = (() => {
- // /// import
- let currentImportTimer = null;
+ let pad;
+ // /// import
const addImportFrames = () => {
$('#import .importframe').remove();
const iframe = $('