From 308e7b98b1a2048064904e534907875803c7fe6e Mon Sep 17 00:00:00 2001 From: Jovans025 <30611661+Jovans025@users.noreply.github.com> Date: Fri, 23 Oct 2020 14:58:56 +0800 Subject: [PATCH] Update index.js Adding try catch handler, since there are times that files are not compress to the right directory then reading the file may result into an error which break the server. --- index.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 96c3ac3..69b50ec 100644 --- a/index.js +++ b/index.js @@ -1474,8 +1474,12 @@ var index = function (input, output, option, findfileop, enginejpg, enginepng, e function getFilesizeInBytes(filename) { - filename = fs.statSync(filename) - return filename["size"]; + try { + filename = fs.statSync(filename) + return filename["size"]; + } catch { + return 0 + } }