笔记和标签同步BUGs

1. 修复不能添加已删除的tag
2. FullSync时可能导致一些笔记为Dirty
3. 笔记错误同步信息显示
This commit is contained in:
life
2017-01-20 12:45:56 +08:00
parent ee0d4fa803
commit 21f5306f79
7 changed files with 115 additions and 64 deletions

32
node_modules/note.js generated vendored
View File

@@ -616,7 +616,7 @@ var Note = {
var me = this;
// 修复内容, 修改图片, 附件链接为本地链接
content = me.fixNoteContent(content);
db.notes.update({NoteId: noteId}, { $set: {Err: null, Content: content, InitSync: false, IsContentDirty: false} }, {}, function (err, numReplaced) {
db.notes.update({NoteId: noteId}, { $set: {Err: '', Content: content, InitSync: false, IsContentDirty: false} }, {}, function (err, numReplaced) {
if(err) {
log(err);
callback && callback(false);
@@ -965,7 +965,7 @@ var Note = {
// 不要服务器上的
delete note['UpdatedTime'];
delete note['CreatedTime'];
note.Err = null;
note.Err = '';
db.notes.update({NoteId: note.NoteId}, {$set: note}, {}, function (err, cnt) { // Callback is optional
// console.log('re:');
@@ -1056,6 +1056,7 @@ var Note = {
delete note['Files'];
delete note['UpdatedTime'];
delete note['CreatedTime'];
note.Err = '';
// multi: true, 避免有历史的笔记有问题
db.notes.update({NoteId: note.NoteId}, {$set: note}, {multi: true}, function(err, n) {
@@ -1663,10 +1664,10 @@ var Note = {
var me = this;
setTimeout(function() {
// 内容
console.log("syncContentAndImagesAndAttachs..................." + note.NoteId);
console.log(" syncContentAndImagesAndAttachs..... " + note.NoteId);
me.getNoteContent(note.NoteId, function(noteAndContent) {
if(noteAndContent) {
console.log('sync content ' + note.NoteId + ' ok');
console.log(' sync content ' + note.NoteId + ' ok');
var content = noteAndContent.Content;
Web.contentSynced(note.NoteId, note.Content);
// 图片
@@ -1812,21 +1813,30 @@ var Note = {
})(title);
}
},
// 这里,有一个大BUG, 导致全量同步时会修改一些笔记的IsDirty
// title==null时传过来
// tag.js调用
// 删除包含title的笔记
// 先删除tag, 再删除tag.js
updateNoteToDeleteTag: function(title, callback) {
if (!title) {
return callback({});
}
var updates = {}; // noteId =>
var userId = User.getCurActiveUserId();
// console.log('updateNoteToDeleteTag--');
console.log(' updateNoteToDeleteTag', title);
db.notes.find({UserId: userId, LocalIsDelete: false , Tags: {$in: [title]}}, function(err, notes) {
console.log(notes);
console.log( 'updateNoteToDeleteTag notes', err, title, notes);
if(!err && notes && notes.length > 0) {
for(var i in notes) {
for(var i = 0; i < notes.length; ++i) {
var note = notes[i];
var tags = note.Tags;
// 删除之
for(var j in tags) {
for(var j = 0; j < tags.length; ++j) {
if(tags[j] == title) {
tags = tags.splice(j, 1);
// tags = tags.splice(j, 1); // 之前是这样, 返回的是删除之后的
tags.splice(j, 1);
break;
}
}
@@ -1834,8 +1844,8 @@ var Note = {
note.IsDirty = true;
updates[note.NoteId] = note;
db.notes.update({_id: note._id}, {$set: {Tags: tags, IsDirty: true}}, function(err) {
console.log("??");
console.log(err);
// console.log("??");
// console.log(err);
callback(updates);
});
}