summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorCheng-Han, Wu2016-06-01 23:19:47 +0800
committerCheng-Han, Wu2016-06-01 23:19:47 +0800
commit03bdee23ffbcdd0f1b24668da9d4168f7809d8e0 (patch)
tree4b502cfbe92bad40f24f76bda7e94ee2e30c629b /lib
parentb9060395ca25f991cc02bbfdc683bbe6e9b35b30 (diff)
Update note model on create doc will use the created time of the doc in filesystem
Diffstat (limited to 'lib')
-rw-r--r--lib/models/note.js2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/models/note.js b/lib/models/note.js
index 4c501d2d..2b51c87c 100644
--- a/lib/models/note.js
+++ b/lib/models/note.js
@@ -208,9 +208,11 @@ module.exports = function (sequelize, DataTypes) {
filePath = path.join(config.docspath, note.alias + '.md');
}
if (Note.checkFileExist(filePath)) {
+ var fsCreatedTime = moment(fs.statSync(filePath).ctime);
body = fs.readFileSync(filePath, 'utf8');
note.title = LZString.compressToBase64(Note.parseNoteTitle(body));
note.content = LZString.compressToBase64(body);
+ note.createdAt = fsCreatedTime;
}
}
// if no permission specified and have owner then give editable permission, else default permission is freely