删除笔记后, 删除附件

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