ImportHandler: importing files with unknown extension work again when allowUnknownFileEnds is true
By specification, when settings.allowUnknownFileEnds is true and the user tries to import a file with an unknown extension (this includes no extension), Etherpad tries to import it as txt. This broke in Etherpad 1.8.0, that abruptly terminates the processing with an UnhandledPromiseRejectionWarning. This patch restores the intended behaviour, and allows to import as text a file with an unknown extension (on no extension). In order to catch the UnhandledPromiseRejectionWarning we had to use fsp_rename(), which is declared earlier in the code and is promised based instead of fs.rename(), which is callback based. Fixes #3710.pull/3720/head
parent
a0579c90db
commit
28102d8e1f
|
@ -101,7 +101,7 @@ async function doImport(req, res, padId)
|
||||||
let oldSrcFile = srcFile;
|
let oldSrcFile = srcFile;
|
||||||
|
|
||||||
srcFile = path.join(path.dirname(srcFile), path.basename(srcFile, fileEnding) + ".txt");
|
srcFile = path.join(path.dirname(srcFile), path.basename(srcFile, fileEnding) + ".txt");
|
||||||
await fs.rename(oldSrcFile, srcFile);
|
await fsp_rename(oldSrcFile, srcFile);
|
||||||
} else {
|
} else {
|
||||||
console.warn("Not allowing unknown file type to be imported", fileEnding);
|
console.warn("Not allowing unknown file type to be imported", fileEnding);
|
||||||
throw "uploadFailed";
|
throw "uploadFailed";
|
||||||
|
|
Loading…
Reference in New Issue