diff options
author | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2020-03-06 22:53:09 -0500 |
---|---|---|
committer | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2020-03-19 17:43:55 -0400 |
commit | 4b39f0da46508c8802fdfe726721fbad62281af1 (patch) | |
tree | 3b04eccc1d436b458be19eb2ddddcddbf6ec6406 | |
parent | e31abb560ad402ff7927d435b5fa395d255a8791 (diff) | |
download | patchfoo-4b39f0da46508c8802fdfe726721fbad62281af1.tar.gz patchfoo-4b39f0da46508c8802fdfe726721fbad62281af1.zip |
drafts: better error handling; skip dotfiles
-rw-r--r-- | lib/app.js | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -1512,11 +1512,12 @@ App.prototype.saveDraft = function (id, url, form, content, cb) { App.prototype.getDraft = function (id, cb) { var self = this - fs.readFile(path.join(self.draftsDir, id), 'utf8', function (err, data) { + var filename = path.join(self.draftsDir, id) + fs.readFile(filename, 'utf8', function (err, data) { if (err) return cb(err) var draft try { draft = JSON.parse(data) } - catch(e) { return cb(e) } + catch(e) { return cb(new Error('JSON Error reading ' + filename + ': ' + e.stack)) } draft.id = id cb(null, draft) }) @@ -1533,6 +1534,9 @@ function compareMtime(a, b) { function statAll(files, dir, cb) { pull( pull.values(files), + pull.filter(function (file) { + return !/^\./.test(file) + }), paramap(function (file, cb) { fs.stat(path.join(dir, file), function (err, stats) { if (err) return cb(err) |