mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
sync debugging tweaks etc.
This commit is contained in:
parent
2a9a8da045
commit
1c501beea9
@ -1,5 +1,6 @@
|
|||||||
const sql = require('./sql');
|
const sql = require('./sql');
|
||||||
const utils = require('./utils');
|
const utils = require('./utils');
|
||||||
|
const log = require('./log');
|
||||||
|
|
||||||
async function addEvent(comment) {
|
async function addEvent(comment) {
|
||||||
await addNoteEvent(null, comment);
|
await addNoteEvent(null, comment);
|
||||||
@ -11,6 +12,8 @@ async function addNoteEvent(noteId, comment) {
|
|||||||
comment: comment,
|
comment: comment,
|
||||||
date_added: utils.nowTimestamp()
|
date_added: utils.nowTimestamp()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
log.info("Event log for " + noteId + ": " + comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
@ -37,8 +37,8 @@ async function createNewNote(parentNoteId, note, browserId) {
|
|||||||
|
|
||||||
await sql.doInTransaction(async () => {
|
await sql.doInTransaction(async () => {
|
||||||
await sql.addAudit(audit_category.CREATE_NOTE, browserId, noteId);
|
await sql.addAudit(audit_category.CREATE_NOTE, browserId, noteId);
|
||||||
await sql.addNoteTreeSync(noteId, browserId);
|
await sql.addNoteTreeSync(noteId);
|
||||||
await sql.addNoteSync(noteId, browserId);
|
await sql.addNoteSync(noteId);
|
||||||
|
|
||||||
const now = utils.nowTimestamp();
|
const now = utils.nowTimestamp();
|
||||||
|
|
||||||
@ -167,8 +167,8 @@ async function deleteNote(noteId, browserId) {
|
|||||||
await sql.execute("update notes_tree set is_deleted = 1, date_modified = ? where note_id = ?", [now, noteId]);
|
await sql.execute("update notes_tree set is_deleted = 1, date_modified = ? where note_id = ?", [now, noteId]);
|
||||||
await sql.execute("update notes set is_deleted = 1, date_modified = ? where note_id = ?", [now, noteId]);
|
await sql.execute("update notes set is_deleted = 1, date_modified = ? where note_id = ?", [now, noteId]);
|
||||||
|
|
||||||
await sql.addNoteTreeSync(noteId, browserId);
|
await sql.addNoteTreeSync(noteId);
|
||||||
await sql.addNoteSync(noteId, browserId);
|
await sql.addNoteSync(noteId);
|
||||||
|
|
||||||
await sql.addAudit(audit_category.DELETE_NOTE, browserId, noteId);
|
await sql.addAudit(audit_category.DELETE_NOTE, browserId, noteId);
|
||||||
}
|
}
|
||||||
|
@ -304,7 +304,7 @@ async function updateNote(entity, links, sourceId) {
|
|||||||
logSync("Update/sync note " + entity.note_id);
|
logSync("Update/sync note " + entity.note_id);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
await eventLog.addNoteEvent(entity.note_id, "Sync conflict in note <note>");
|
await eventLog.addNoteEvent(entity.note_id, "Sync conflict in note <note>, " + utils.formatTwoTimestamps(origNote.date_modified, entity.date_modified));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,7 +323,7 @@ async function updateNoteTree(entity, sourceId) {
|
|||||||
logSync("Update/sync note tree " + entity.note_id);
|
logSync("Update/sync note tree " + entity.note_id);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
await eventLog.addNoteEvent(entity.note_id, "Sync conflict in note tree <note>");
|
await eventLog.addNoteEvent(entity.note_id, "Sync conflict in note tree <note>, " + utils.formatTwoTimestamps(orig.date_modified, entity.date_modified));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -340,7 +340,7 @@ async function updateNoteHistory(entity, sourceId) {
|
|||||||
logSync("Update/sync note history " + entity.note_history_id);
|
logSync("Update/sync note history " + entity.note_history_id);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
await eventLog.addNoteEvent(entity.note_id, "Sync conflict in note history for <note>");
|
await eventLog.addNoteEvent(entity.note_id, "Sync conflict in note history for <note>, " + utils.formatTwoTimestamps(orig.date_modified_to, entity.date_modified_to));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -372,7 +372,7 @@ async function updateOptions(entity, sourceId) {
|
|||||||
await eventLog.addEvent("Synced option " + entity.opt_name);
|
await eventLog.addEvent("Synced option " + entity.opt_name);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
await eventLog.addEvent("Sync conflict in options for " + entity.opt_name);
|
await eventLog.addEvent("Sync conflict in options for " + entity.opt_name + ", " + utils.formatTwoTimestamps(orig.date_modified, entity.date_modified));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,6 +48,16 @@ function isElectron() {
|
|||||||
return !!process.versions['electron'];
|
return !!process.versions['electron'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function formatDateTimeFromTS(timestamp) {
|
||||||
|
const date = new Date(timestamp * 1000);
|
||||||
|
|
||||||
|
return date.toISOString();
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatTwoTimestamps(origTS, newTS) {
|
||||||
|
return "orig: " + formatDateTimeFromTS(origTS) + ", new: " + formatDateTimeFromTS(newTS);
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
randomSecureToken,
|
randomSecureToken,
|
||||||
randomString,
|
randomString,
|
||||||
@ -57,5 +67,6 @@ module.exports = {
|
|||||||
fromBase64,
|
fromBase64,
|
||||||
hmac,
|
hmac,
|
||||||
browserId,
|
browserId,
|
||||||
isElectron
|
isElectron,
|
||||||
|
formatTwoTimestamps
|
||||||
};
|
};
|
Loading…
x
Reference in New Issue
Block a user