mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
last_synced is now updated after sync is completed
This commit is contained in:
parent
18d23af01a
commit
f6033705a7
@ -4,11 +4,13 @@ const express = require('express');
|
|||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
const sql = require('../../services/sql');
|
const sql = require('../../services/sql');
|
||||||
const auth = require('../../services/auth');
|
const auth = require('../../services/auth');
|
||||||
|
const utils = require('../../services/utils');
|
||||||
|
|
||||||
router.get('/changed/:since', auth.checkApiAuth, async (req, res, next) => {
|
router.get('/changed/:since', auth.checkApiAuth, async (req, res, next) => {
|
||||||
const since = parseInt(req.params.since);
|
const since = parseInt(req.params.since);
|
||||||
|
|
||||||
res.send({
|
res.send({
|
||||||
|
'syncTimestamp': utils.nowTimestamp(),
|
||||||
'tree': await sql.getResults("select * from notes_tree where date_modified >= ?", [since]),
|
'tree': await sql.getResults("select * from notes_tree where date_modified >= ?", [since]),
|
||||||
'notes': await sql.getFlattenedResults('note_id', "select note_id from notes where date_modified >= ?", [since]),
|
'notes': await sql.getFlattenedResults('note_id', "select note_id from notes where date_modified >= ?", [since]),
|
||||||
'audit_log': await sql.getResults("select * from audit_log where date_modified >= ?", [since])
|
'audit_log': await sql.getResults("select * from audit_log where date_modified >= ?", [since])
|
||||||
|
@ -29,7 +29,7 @@ async function sync() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
sql.beginTransaction();
|
await sql.beginTransaction();
|
||||||
|
|
||||||
for (const treeItem of resp.tree) {
|
for (const treeItem of resp.tree) {
|
||||||
delete treeItem['id'];
|
delete treeItem['id'];
|
||||||
@ -73,10 +73,12 @@ async function sync() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sql.commit();
|
await sql.setOption('last_synced', syncTimestamp);
|
||||||
|
|
||||||
|
await sql.commit();
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
sql.rollback();
|
await sql.rollback();
|
||||||
|
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user