aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2020-03-06 22:53:09 -0500
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2020-03-19 17:43:55 -0400
commit4b39f0da46508c8802fdfe726721fbad62281af1 (patch)
tree3b04eccc1d436b458be19eb2ddddcddbf6ec6406
parente31abb560ad402ff7927d435b5fa395d255a8791 (diff)
downloadpatchfoo-4b39f0da46508c8802fdfe726721fbad62281af1.tar.gz
patchfoo-4b39f0da46508c8802fdfe726721fbad62281af1.zip
drafts: better error handling; skip dotfiles
-rw-r--r--lib/app.js8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/app.js b/lib/app.js
index f223745..f45e6f9 100644
--- a/lib/app.js
+++ b/lib/app.js
@@ -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)