mirror of
https://github.com/zadam/trilium.git
synced 2024-09-21 08:06:03 +08:00
sync fixes
This commit is contained in:
parent
f499872809
commit
1a36daa088
|
@ -2,7 +2,6 @@
|
||||||
"name": "trilium",
|
"name": "trilium",
|
||||||
"description": "Trilium",
|
"description": "Trilium",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"private": true,
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node ./bin/www",
|
"start": "node ./bin/www",
|
||||||
"test-electron": "xo",
|
"test-electron": "xo",
|
||||||
|
|
|
@ -191,7 +191,6 @@ async function updateNote(noteId, newNote, ctx) {
|
||||||
//await sql.insert("links", link);
|
//await sql.insert("links", link);
|
||||||
}
|
}
|
||||||
|
|
||||||
await sync_table.addNoteTreeSync(noteId);
|
|
||||||
await sync_table.addNoteSync(noteId);
|
await sync_table.addNoteSync(noteId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -224,13 +223,13 @@ async function deleteNote(noteTreeId, browserId) {
|
||||||
|
|
||||||
const noteId = await sql.getSingleValue("SELECT note_id FROM notes_tree WHERE note_tree_id = ?", [noteTreeId]);
|
const noteId = await sql.getSingleValue("SELECT note_id FROM notes_tree WHERE note_tree_id = ?", [noteTreeId]);
|
||||||
|
|
||||||
const notDeletedNoteTreesCount = await sql.getSingleValue("SELECT COUNT(*) FROM notes_tree WHERE note_id = ?", [noteId]);
|
const notDeletedNoteTreesCount = await sql.getSingleValue("SELECT COUNT(*) FROM notes_tree WHERE note_id = ? AND is_deleted = 0", [noteId]);
|
||||||
|
|
||||||
if (!notDeletedNoteTreesCount) {
|
if (!notDeletedNoteTreesCount) {
|
||||||
await sql.execute("UPDATE notes SET is_deleted = 1, date_modified = ? WHERE note_id = ?", [now, noteTreeId]);
|
await sql.execute("UPDATE notes SET is_deleted = 1, date_modified = ? WHERE note_id = ?", [now, noteId]);
|
||||||
await sync_table.addNoteSync(noteTreeId);
|
await sync_table.addNoteSync(noteId);
|
||||||
|
|
||||||
const children = await sql.getResults("SELECT note_tree_id FROM notes_tree WHERE note_pid = ? AND is_deleted = 0", [noteTreeId]);
|
const children = await sql.getResults("SELECT note_tree_id FROM notes_tree WHERE note_pid = ? AND is_deleted = 0", [noteId]);
|
||||||
|
|
||||||
for (const child of children) {
|
for (const child of children) {
|
||||||
await deleteNote(child.note_tree_id, browserId);
|
await deleteNote(child.note_tree_id, browserId);
|
||||||
|
|
|
@ -121,10 +121,12 @@ async function pullSync(syncContext) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("Pulling ", sync);
|
|
||||||
|
|
||||||
const resp = await syncRequest(syncContext, 'GET', "/api/sync/" + sync.entity_name + "/" + encodeURIComponent(sync.entity_id));
|
const resp = await syncRequest(syncContext, 'GET', "/api/sync/" + sync.entity_name + "/" + encodeURIComponent(sync.entity_id));
|
||||||
|
|
||||||
|
if (!resp) {
|
||||||
|
log.error("Empty response to pull for " + sync.entity_name + ", id=" + sync.entity_id);
|
||||||
|
}
|
||||||
|
|
||||||
if (sync.entity_name === 'notes') {
|
if (sync.entity_name === 'notes') {
|
||||||
await syncUpdate.updateNote(resp.entity, resp.links, syncContext.sourceId);
|
await syncUpdate.updateNote(resp.entity, resp.links, syncContext.sourceId);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue