笔记和标签同步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

36
node_modules/sync.js generated vendored
View File

@@ -497,20 +497,19 @@ var Sync = {
// 1) 服务器端删除了, 本地肯定删除
if(tag.IsDeleted) {
log('delete tag: ');
log(tag);
console.log(' delete tag: ', tag);
Tag.deleteTag(tag.Tag, function() {
// me._syncInfo.tag.deletes.push(tag.Tag);
me.fixSynced('tag', 'deletes', tag.Tag);
canCall();
}, true);
}, true, me.fullSyncStart);
return;
}
// 2) 查看本地的, 与本地合并
Tag.getTag(tag.Tag, function(tagLocal) {
// 2.1 本地没有, 表示是新建
if(!tagLocal) {
log('add tag: ...')
console.log(' add tag: ...')
Tag.addOrUpdateTag(tag.Tag, function(tagAdded) {
// me._syncInfo.tag.adds.push(tagAdded);
me.fixSynced('tag', 'adds', tagAdded);
@@ -586,6 +585,7 @@ var Sync = {
var me = this;
me._stop = false;
me._initSyncInfo();
me.fullSyncStart = true;
User.getAllLastSyncState(function(lastUsn, notebookUsn, noteUsn, tagUsn) {
// 不可能会有lastUsn吧
@@ -605,7 +605,7 @@ var Sync = {
tagUsn = -1;
}
// console.log('fullSync------ ' + notebookUsn + ' ' + noteUsn + ' ' + tagUsn);
console.log('fullSync ' + notebookUsn + ' ' + noteUsn + ' ' + tagUsn);
// Web.syncNotebookFinish();
// 同步笔记本
@@ -620,6 +620,7 @@ var Sync = {
// 同步标签
me.syncTag(tagUsn, function(ok) {
if (ok) {
me.fullSyncStart = false;
// 更新上次同步时间
me.updateLastSyncState(function() {
// send changes
@@ -628,16 +629,19 @@ var Sync = {
});
}
else {
me.fullSyncStart = false;
console.error('syncTag error....');
callback && callback(me._syncInfo, false);
}
});
} else {
me.fullSyncStart = false;
console.error('syncNote error.... 跳过tag');
callback && callback(me._syncInfo, false);
}
});
} else {
me.fullSyncStart = false;
console.error('syncNotebook error.... 跳过note,tag');
callback && callback(me._syncInfo, false);
}
@@ -1015,6 +1019,11 @@ var Sync = {
Api.deleteTrash(note, function(ret) {
if(Common.isOk(ret)) {
me.checkNeedIncSyncAgain(ret.Usn);
// 本地删除了的, 服务端没有, 直接删除本地的
} else if (typeof ret == 'object' && ret.Msg == 'notExists') {
console.log( '本地删除了的, 服务端没有, 直接删除本地的');
Note.deleteLocalNote(note.NoteId);
}
return cb();
});
@@ -1121,7 +1130,10 @@ var Sync = {
if(!Common.isOk(newTag)) {
return cb();
}
me._syncInfo.note.changeAdds.push(newTag);
// 更新, 添加usn
Tag.setNotDirtyAndUsn(tag.Tag, newTag.Usn);
me._syncInfo.tag.changeAdds.push(newTag); // 之前是note.changeAdds
// Tag.updateTagForce(newTag);
me.checkNeedIncSyncAgain(newTag.Usn);
cb();
@@ -1130,10 +1142,16 @@ var Sync = {
// 删除, 不管它了
Api.deleteTag(tag, function(ret) {
if(Common.isOk(ret)) {
Tag.setNotDirty(tag.Tag);
me.checkNeedIncSyncAgain(ret.Usn);
} else {
// 有问题, 可能本地不存在
Tag.setNotDirty(tag);
// 本地删除了的, 服务端没有, 直接删除本地的
} else if (typeof ret == 'object') {
if (ret.Msg == 'notExists') {
console.log( 'tag本地删除了的, 服务端没有, 直接删除本地的');
Tag.deleteLocalTag(tag.Tag);
} else if(ret.Msg == 'conflict') {
Tag.setNotDirty(tag.Tag);
}
}
return cb();
});