mirror of
https://github.com/zadam/trilium.git
synced 2025-02-27 00:29:21 +08:00
created sync table
This commit is contained in:
parent
8630b3685d
commit
d88d562d63
3 changed files with 24 additions and 2 deletions
15
migrations/0020__sync.sql
Normal file
15
migrations/0020__sync.sql
Normal file
|
@ -0,0 +1,15 @@
|
|||
CREATE TABLE `sync` (
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
`entity_name` TEXT NOT NULL,
|
||||
`entity_id` TEXT NOT NULL,
|
||||
`sync_date` INTEGER NOT NULL
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX `IDX_sync_entity_name_id` ON `sync` (
|
||||
`entity_name`,
|
||||
`entity_id`
|
||||
);
|
||||
|
||||
CREATE INDEX `IDX_sync_sync_date` ON `sync` (
|
||||
`sync_date`
|
||||
);
|
|
@ -3,7 +3,7 @@ const sql = require('./sql');
|
|||
const fs = require('fs-extra');
|
||||
const log = require('./log');
|
||||
|
||||
const APP_DB_VERSION = 19;
|
||||
const APP_DB_VERSION = 20;
|
||||
const MIGRATIONS_DIR = "./migrations";
|
||||
|
||||
async function migrate() {
|
||||
|
|
|
@ -129,6 +129,13 @@ async function pushSync(cookieJar, syncLog) {
|
|||
|
||||
lastSyncedPush = oldestUnsyncedDateModified;
|
||||
|
||||
// if the sync started in the same second as the last changes then it's possible we synced only parts
|
||||
// of this second's changes. In that case we'll leave the last_synced_push as it is and stop the sync
|
||||
// so next time we'll re-do this second again, this guaranteeing all changes have been pushed
|
||||
if (lastSyncedPush === syncStarted) {
|
||||
return;
|
||||
}
|
||||
|
||||
await sql.setOption('last_synced_push', lastSyncedPush);
|
||||
});
|
||||
}
|
||||
|
@ -185,7 +192,7 @@ async function sync() {
|
|||
|
||||
await pushSync(cookieJar, syncLog);
|
||||
|
||||
//await pullSync(cookieJar, syncLog);
|
||||
await pullSync(cookieJar, syncLog);
|
||||
}
|
||||
catch (e) {
|
||||
logSync("sync failed: " + e.stack, syncLog);
|
||||
|
|
Loading…
Reference in a new issue