From 28102d8e1ff4bde5d7078c6e5d217bf520fd13c0 Mon Sep 17 00:00:00 2001 From: Tudor Constantin Date: Mon, 16 Mar 2020 20:56:50 +0200 Subject: [PATCH] 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. --- src/node/handler/ImportHandler.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node/handler/ImportHandler.js b/src/node/handler/ImportHandler.js index d2bd05289..691bea42c 100644 --- a/src/node/handler/ImportHandler.js +++ b/src/node/handler/ImportHandler.js @@ -101,7 +101,7 @@ async function doImport(req, res, padId) let oldSrcFile = srcFile; srcFile = path.join(path.dirname(srcFile), path.basename(srcFile, fileEnding) + ".txt"); - await fs.rename(oldSrcFile, srcFile); + await fsp_rename(oldSrcFile, srcFile); } else { console.warn("Not allowing unknown file type to be imported", fileEnding); throw "uploadFailed";