mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
fixed sync bug
This commit is contained in:
parent
a5735961a4
commit
9e3515b122
@ -22,6 +22,12 @@ router.post('', auth.checkApiAuth, async (req, res, next) => {
|
|||||||
"AND date_modified >= ? AND note_id = ? AND category IN (?)", [browserId, currentNoteDateModified, currentNoteId,
|
"AND date_modified >= ? AND note_id = ? AND category IN (?)", [browserId, currentNoteDateModified, currentNoteId,
|
||||||
audit_category.UPDATE_CONTENT]);
|
audit_category.UPDATE_CONTENT]);
|
||||||
|
|
||||||
|
if (currentNoteChangesCount > 0) {
|
||||||
|
console.log("Current note changed!");
|
||||||
|
console.log("SELECT COUNT(*) FROM audit_log WHERE (browser_id IS NULL OR browser_id != '" + browserId + "') " +
|
||||||
|
"AND date_modified >= " + currentNoteDateModified + " AND note_id = '" + currentNoteId + "' AND category IN ('" + audit_category.UPDATE_CONTENT + "')");
|
||||||
|
}
|
||||||
|
|
||||||
let changesToPushCount = 0;
|
let changesToPushCount = 0;
|
||||||
|
|
||||||
if (sync.isSyncSetup) {
|
if (sync.isSyncSetup) {
|
||||||
|
@ -51,13 +51,13 @@ async function pullSync(syncContext, syncLog) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sync.entity_name === 'notes') {
|
if (sync.entity_name === 'notes') {
|
||||||
await updateNote(resp.entity, resp.links, sync.source_id, syncLog);
|
await updateNote(resp.entity, resp.links, syncContext.sourceId, syncLog);
|
||||||
}
|
}
|
||||||
else if (sync.entity_name === 'notes_tree') {
|
else if (sync.entity_name === 'notes_tree') {
|
||||||
await updateNoteTree(resp, sync.source_id, syncLog);
|
await updateNoteTree(resp, syncContext.sourceId, syncLog);
|
||||||
}
|
}
|
||||||
else if (sync.entity_name === 'notes_history') {
|
else if (sync.entity_name === 'notes_history') {
|
||||||
await updateNoteHistory(resp, sync.source_id, syncLog);
|
await updateNoteHistory(resp, syncContext.sourceId, syncLog);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
logSyncError("Unrecognized entity type " + sync.entity_name, e, syncLog);
|
logSyncError("Unrecognized entity type " + sync.entity_name, e, syncLog);
|
||||||
@ -129,9 +129,7 @@ async function pushSync(syncContext, syncLog) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("sync: ", sync);
|
if (sync.sourceId === syncContext.source_id) {
|
||||||
|
|
||||||
if (sync.sourceId === syncContext.sourceId) {
|
|
||||||
logSync("Skipping sync " + sync.entity_name + " " + sync.entity_id + " because it originates from sync target", syncLog);
|
logSync("Skipping sync " + sync.entity_name + " " + sync.entity_id + " because it originates from sync target", syncLog);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -196,8 +194,6 @@ async function sync() {
|
|||||||
|
|
||||||
const syncContext = await login(syncLog);
|
const syncContext = await login(syncLog);
|
||||||
|
|
||||||
console.log("sync context: ", syncContext);
|
|
||||||
|
|
||||||
await pullSync(syncContext, syncLog);
|
await pullSync(syncContext, syncLog);
|
||||||
|
|
||||||
await pushSync(syncContext, syncLog);
|
await pushSync(syncContext, syncLog);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user