Skip to content

Commit

Permalink
Added error handling for malformed .doentry files
Browse files Browse the repository at this point in the history
  • Loading branch information
pwaldhauer committed Jul 11, 2013
1 parent 72b791e commit 7c52f2b
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/output/DayOneExport.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,18 @@ DayOneExport.prototype.loadEntries = function loadEntries() {
that.entryCache = {};

fs.readdirSync(fullpath).forEach(function(file) {
var entry = plist.parseFileSync(path.join(fullpath, file));
try {
var entry = plist.parseFileSync(path.join(fullpath, file));

// Found a generated entry for this day
if(entry['Tags'] && entry['Tags'].indexOf(that.options.tag) != -1) {
var date = moment(entry['Creation Date']);
that.entryCache[date.format('YYYYMMDD')] = entry;
// Found a generated entry for this day
if(entry['Tags'] && entry['Tags'].indexOf(that.options.tag) != -1) {
var date = moment(entry['Creation Date']);
that.entryCache[date.format('YYYYMMDD')] = entry;
}
} catch(err) {
console.log('Skipping malformed entry: ' + file);
return;
}

});
}

Expand Down

0 comments on commit 7c52f2b

Please sign in to comment.