mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
sync fixes
This commit is contained in:
parent
b660238a40
commit
5be7f003ca
@ -215,7 +215,8 @@ class Note extends AbstractEntity {
|
|||||||
entityId: this.noteId,
|
entityId: this.noteId,
|
||||||
hash: hash,
|
hash: hash,
|
||||||
isErased: false,
|
isErased: false,
|
||||||
utcDateChanged: pojo.utcDateModified
|
utcDateChanged: pojo.utcDateModified,
|
||||||
|
isSynced: true
|
||||||
}, null);
|
}, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +131,8 @@ class NoteRevision extends AbstractEntity {
|
|||||||
entityId: this.noteRevisionId,
|
entityId: this.noteRevisionId,
|
||||||
hash: hash,
|
hash: hash,
|
||||||
isErased: false,
|
isErased: false,
|
||||||
utcDateChanged: this.getUtcDateChanged()
|
utcDateChanged: this.getUtcDateChanged(),
|
||||||
|
isSynced: true
|
||||||
}, null);
|
}, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ const dateUtils = require('./date_utils');
|
|||||||
const attributeService = require('./attributes');
|
const attributeService = require('./attributes');
|
||||||
const noteRevisionService = require('./note_revisions');
|
const noteRevisionService = require('./note_revisions');
|
||||||
const becca = require("../becca/becca");
|
const becca = require("../becca/becca");
|
||||||
|
const utils = require("../services/utils");
|
||||||
|
|
||||||
class ConsistencyChecks {
|
class ConsistencyChecks {
|
||||||
constructor(autoFix) {
|
constructor(autoFix) {
|
||||||
@ -291,13 +292,23 @@ class ConsistencyChecks {
|
|||||||
|
|
||||||
if (note.isProtected) {
|
if (note.isProtected) {
|
||||||
// this is wrong for non-erased notes but we cannot set a valid value for protected notes
|
// this is wrong for non-erased notes but we cannot set a valid value for protected notes
|
||||||
|
const utcDateModified = dateUtils.utcNowDateTime();
|
||||||
|
|
||||||
sql.upsert("note_contents", "noteId", {
|
sql.upsert("note_contents", "noteId", {
|
||||||
noteId: noteId,
|
noteId: noteId,
|
||||||
content: null,
|
content: null,
|
||||||
utcDateModified: dateUtils.utcNowDateTime()
|
utcDateModified: utcDateModified
|
||||||
});
|
});
|
||||||
|
|
||||||
entityChangesService.addEntityChange('note_contents', noteId, "consistency_checks");
|
const hash = utils.hash(noteId + "|null");
|
||||||
|
|
||||||
|
entityChangesService.addEntityChange({
|
||||||
|
entityName: 'note_contents',
|
||||||
|
entityId: noteId,
|
||||||
|
hash: hash,
|
||||||
|
isErased: false,
|
||||||
|
utcDateChanged: utcDateModified
|
||||||
|
}, null);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// empty string might be wrong choice for some note types but it's a best guess
|
// empty string might be wrong choice for some note types but it's a best guess
|
||||||
|
@ -25,8 +25,8 @@ function insertEntityChange(entityName, entityId, hash, isErased, utcDateChanged
|
|||||||
return entityChange;
|
return entityChange;
|
||||||
}
|
}
|
||||||
|
|
||||||
function addEntityChange(entityChange, sourceId, isSynced) {
|
function addEntityChange(entityChange, sourceId) {
|
||||||
const localEntityChange = insertEntityChange(entityChange.entityName, entityChange.entityId, entityChange.hash, entityChange.isErased, entityChange.utcDateChanged, sourceId, isSynced);
|
const localEntityChange = insertEntityChange(entityChange.entityName, entityChange.entityId, entityChange.hash, entityChange.isErased, entityChange.utcDateChanged, sourceId, entityChange.isSynced);
|
||||||
|
|
||||||
cls.addEntityChange(localEntityChange);
|
cls.addEntityChange(localEntityChange);
|
||||||
}
|
}
|
||||||
@ -37,7 +37,8 @@ function addNoteReorderingEntityChange(parentNoteId, sourceId) {
|
|||||||
entityId: parentNoteId,
|
entityId: parentNoteId,
|
||||||
hash: 'N/A',
|
hash: 'N/A',
|
||||||
isErased: false,
|
isErased: false,
|
||||||
utcDateChanged: dateUtils.utcNowDateTime()
|
utcDateChanged: dateUtils.utcNowDateTime(),
|
||||||
|
isSynced: true
|
||||||
}, sourceId);
|
}, sourceId);
|
||||||
|
|
||||||
const eventService = require('./events');
|
const eventService = require('./events');
|
||||||
@ -104,7 +105,8 @@ function fillEntityChanges(entityName, entityPrimaryKey, condition = '') {
|
|||||||
entityId,
|
entityId,
|
||||||
hash: entity.generateHash(),
|
hash: entity.generateHash(),
|
||||||
isErased: false,
|
isErased: false,
|
||||||
utcDateChanged: entity.getUtcDateChanged()
|
utcDateChanged: entity.getUtcDateChanged(),
|
||||||
|
isSynced: entityName !== 'options' || !!entity.isSynced
|
||||||
}, null);
|
}, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ const request = require('./request');
|
|||||||
const ws = require('./ws');
|
const ws = require('./ws');
|
||||||
const entityChangesService = require('./entity_changes');
|
const entityChangesService = require('./entity_changes');
|
||||||
const entityConstructor = require('../becca/entity_constructor');
|
const entityConstructor = require('../becca/entity_constructor');
|
||||||
|
const becca = require("../becca/becca");
|
||||||
|
|
||||||
let proxyToggle = true;
|
let proxyToggle = true;
|
||||||
|
|
||||||
@ -358,6 +359,9 @@ function getLastSyncedPull() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setLastSyncedPull(entityChangeId) {
|
function setLastSyncedPull(entityChangeId) {
|
||||||
|
const lastSyncedPullOption = becca.getOption('lastSyncedPull');
|
||||||
|
lastSyncedPullOption.value = entityChangeId + '';
|
||||||
|
|
||||||
// this way we avoid updating entity_changes which otherwise means that we've never pushed all entity_changes
|
// this way we avoid updating entity_changes which otherwise means that we've never pushed all entity_changes
|
||||||
sql.execute("UPDATE options SET value = ? WHERE name = ?", [entityChangeId, 'lastSyncedPull']);
|
sql.execute("UPDATE options SET value = ? WHERE name = ?", [entityChangeId, 'lastSyncedPull']);
|
||||||
}
|
}
|
||||||
@ -373,6 +377,9 @@ function getLastSyncedPush() {
|
|||||||
function setLastSyncedPush(entityChangeId) {
|
function setLastSyncedPush(entityChangeId) {
|
||||||
ws.setLastSyncedPush(entityChangeId);
|
ws.setLastSyncedPush(entityChangeId);
|
||||||
|
|
||||||
|
const lastSyncedPushOption = becca.getOption('lastSyncedPush');
|
||||||
|
lastSyncedPushOption.value = entityChangeId + '';
|
||||||
|
|
||||||
// this way we avoid updating entity_changes which otherwise means that we've never pushed all entity_changes
|
// this way we avoid updating entity_changes which otherwise means that we've never pushed all entity_changes
|
||||||
sql.execute("UPDATE options SET value = ? WHERE name = ?", [entityChangeId, 'lastSyncedPush']);
|
sql.execute("UPDATE options SET value = ? WHERE name = ?", [entityChangeId, 'lastSyncedPush']);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user