From 34e5c51abe95bd615390751f342a7007804f9070 Mon Sep 17 00:00:00 2001 From: Sergey Konovalov Date: Wed, 25 Sep 2024 11:39:06 +0300 Subject: [PATCH] [bug] Fix crash if folder is empty after downloadFileFromStorage --- FileConverter/sources/converter.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/FileConverter/sources/converter.js b/FileConverter/sources/converter.js index 284b3055..ef05f947 100644 --- a/FileConverter/sources/converter.js +++ b/FileConverter/sources/converter.js @@ -539,9 +539,11 @@ function* processDownloadFromStorage(ctx, dataConvert, cmd, task, tempDirs, auth } else if (fs.existsSync(path.join(tempDirs.source, 'origin.pdf'))) { dataConvert.fileFrom = path.join(tempDirs.source, 'origin.pdf'); } - let fileFromNew = path.join(path.dirname(dataConvert.fileFrom), "Editor.bin"); - fs.renameSync(dataConvert.fileFrom, fileFromNew); - dataConvert.fileFrom = fileFromNew; + if (fs.existsSync(dataConvert.fileFrom)) { + let fileFromNew = path.join(path.dirname(dataConvert.fileFrom), "Editor.bin"); + fs.renameSync(dataConvert.fileFrom, fileFromNew); + dataConvert.fileFrom = fileFromNew; + } } yield changeFormatToExtendedPdf(ctx, dataConvert, cmd);