mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-22 16:36:15 -04:00
build(deps): bump formidable from 2.1.2 to 3.5.0 in /src (#5796)
* build(deps): bump formidable from 2.1.2 to 3.5.0 in /src Bumps [formidable](https://github.com/node-formidable/formidable) from 2.1.2 to 3.5.0. - [Release notes](https://github.com/node-formidable/formidable/releases) - [Changelog](https://github.com/node-formidable/formidable/blob/master/CHANGELOG.md) - [Commits](https://github.com/node-formidable/formidable/commits/v3.5.0) --- updated-dependencies: - dependency-name: formidable dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * formidable migration --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: John McLear <john@mclear.co.uk>
This commit is contained in:
parent
24720abdc8
commit
4da66d19dc
5 changed files with 64 additions and 38 deletions
|
@ -89,24 +89,24 @@ const doImport = async (req, res, padId, authorId) => {
|
|||
maxFileSize: settings.importMaxFileSize,
|
||||
});
|
||||
|
||||
// locally wrapped Promise, since form.parse requires a callback
|
||||
let srcFile = await new Promise((resolve, reject) => {
|
||||
form.parse(req, (err, fields, files) => {
|
||||
if (err != null) {
|
||||
logger.warn(`Import failed due to form error: ${err.stack || err}`);
|
||||
// I hate doing indexOf here but I can't see anything to use...
|
||||
if (err && err.stack && err.stack.indexOf('maxFileSize') !== -1) {
|
||||
return reject(new ImportError('maxFileSize'));
|
||||
}
|
||||
return reject(new ImportError('uploadFailed'));
|
||||
}
|
||||
if (!files.file) {
|
||||
logger.warn('Import failed because form had no file');
|
||||
return reject(new ImportError('uploadFailed'));
|
||||
}
|
||||
resolve(files.file.filepath);
|
||||
});
|
||||
});
|
||||
let srcFile;
|
||||
let files;
|
||||
let fields;
|
||||
try {
|
||||
[fields, files] = await form.parse(req);
|
||||
} catch (err) {
|
||||
logger.warn(`Import failed due to form error: ${err.stack || err}`);
|
||||
if (err.code === Formidable.formidableErrors.biggerThanMaxFileSize) {
|
||||
throw new ImportError('maxFileSize');
|
||||
}
|
||||
throw new ImportError('uploadFailed');
|
||||
}
|
||||
if (!files.file) {
|
||||
logger.warn('Import failed because form had no file');
|
||||
throw new ImportError('uploadFailed');
|
||||
} else {
|
||||
srcFile = files.file[0].filepath;
|
||||
}
|
||||
|
||||
// ensure this is a file ending we know, else we change the file ending to .txt
|
||||
// this allows us to accept source code files like .c or .java
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue