summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSheogorath2018-06-23 21:47:22 +0200
committerSheogorath2018-06-23 23:01:01 +0200
commita2608c319a8c31f9b173dbb5d00221d3ad96739b (patch)
tree63818fa9b2f00ed1d1c796451b74b21e7244cd36 /lib
parent8fe26988d159b8ad3970f54f256245cece3efce5 (diff)
Fix possible error if HackMD is started with wrong workdir
In https://github.com/hackmdio/hackmd/issues/834 is described how starting HackMD crashes when using the wrong working dir. This is caused by a relative path in our upload routine. This change should fix it and prevent future crashes. Signed-off-by: Sheogorath <sheogorath@shivering-isles.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/config/default.js1
-rw-r--r--lib/config/index.js1
-rw-r--r--lib/web/imageRouter/index.js2
3 files changed, 3 insertions, 1 deletions
diff --git a/lib/config/default.js b/lib/config/default.js
index 1b124b3e..f88c17b3 100644
--- a/lib/config/default.js
+++ b/lib/config/default.js
@@ -45,6 +45,7 @@ module.exports = {
errorPath: './public/views/error.ejs',
prettyPath: './public/views/pretty.ejs',
slidePath: './public/views/slide.ejs',
+ uploadsPath: './public/uploads',
// session
sessionName: 'connect.sid',
sessionSecret: 'secret',
diff --git a/lib/config/index.js b/lib/config/index.js
index 7853dbad..b8bf64cc 100644
--- a/lib/config/index.js
+++ b/lib/config/index.js
@@ -173,6 +173,7 @@ config.hackmdPath = path.join(appRootPath, config.hackmdPath)
config.errorPath = path.join(appRootPath, config.errorPath)
config.prettyPath = path.join(appRootPath, config.prettyPath)
config.slidePath = path.join(appRootPath, config.slidePath)
+config.uploadsPath = path.join(appRootPath, config.uploadsPath)
// make config readonly
config = deepFreeze(config)
diff --git a/lib/web/imageRouter/index.js b/lib/web/imageRouter/index.js
index f7e031af..f3c2decf 100644
--- a/lib/web/imageRouter/index.js
+++ b/lib/web/imageRouter/index.js
@@ -16,7 +16,7 @@ imageRouter.post('/uploadimage', function (req, res) {
form.keepExtensions = true
if (config.imageUploadType === 'filesystem') {
- form.uploadDir = 'public/uploads'
+ form.uploadDir = config.uploadsPath
}
form.parse(req, function (err, fields, files) {