From bc60899551fa609e212121f13ca6ffea76e031a3 Mon Sep 17 00:00:00 2001 From: Chris Brame Date: Sat, 2 Feb 2019 00:47:44 -0500 Subject: [PATCH] fix(editor): crash on invalid directory --- src/controllers/editor.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/controllers/editor.js b/src/controllers/editor.js index 71e23c402..34c821cbb 100644 --- a/src/controllers/editor.js +++ b/src/controllers/editor.js @@ -36,6 +36,8 @@ editor.page = function (req, res) { editor.getAssets = function (req, res) { var imageExts = ['.gif', '.png', '.jpg', '.jpeg', '.ico', '.bmp'] + fs.ensureDirSync(path.join(__dirname, '../../public/uploads/assets/upload')) + fs.readdir(path.join(__dirname, '../../public/uploads/assets/upload'), function (err, files) { if (err) return res.status(400).json({ success: false, error: err })