删除笔记后, 删除附件

This commit is contained in:
life
2015-11-15 12:20:23 +08:00
parent f518a903e7
commit 6daba37aa4

11
node_modules/note.js generated vendored
View File

@@ -385,6 +385,8 @@ var Note = {
// TODO 删除附件
db.notes.update({_id: note._id}, {$set: {IsDirty: true, LocalIsDelete: true}}, function(err, n) {
if(n) {
// 删除附件
me.deleteAttachs(note.Attachs);
// 删除历史记录
me.deleteNoteHistory(note.NoteId);
// 如果有tags, 则重新更新tags' count
@@ -702,6 +704,8 @@ var Note = {
if(err) {
callback && callback(false);
} else {
// 删除附件
me.deleteAttachs(note.Attachs);
// 删除历史记录
me.deleteNoteHistory(noteId);
Notebook.reCountNotebookNumberNotes(note.NotebookId);
@@ -1508,12 +1512,13 @@ var Note = {
},
// 删除附件, 在sync时
// 或者, 在删除笔记后
deleteAttachs: function(attachs) {
var me = this;
var fileBasePath = User.getCurUserAttachsPath();
if(!attachs) {
if (!attachs || attachs.length == 0) {
return;
}
var me = this;
var fileBasePath = User.getCurUserAttachsPath();
for(var i in attachs) {
var path = attachs[i].Path;
if(path && path.indexOf(fileBasePath) > 0) {