diff --git a/node_modules/note.js b/node_modules/note.js index 5fb13c63..f8878302 100644 --- a/node_modules/note.js +++ b/node_modules/note.js @@ -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) {