Merge remote-tracking branch 'origin/stable'

# Conflicts:
#	libraries/ckeditor/ckeditor.js.map
#	package.json
#	src/routes/api/login.js
#	src/routes/api/sync.js
#	src/routes/index.js
#	src/services/app_info.js
#	src/services/sync.js
This commit is contained in:
zadam 2020-08-02 20:41:22 +02:00
commit f4a4e746bf
12 changed files with 25 additions and 17 deletions

View File

@ -0,0 +1,4 @@
UPDATE sync SET isSynced = 1 WHERE entityName != 'options' OR (
entityName = 'options'
AND 1 = (SELECT isSynced FROM options WHERE name = sync.entityId)
)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -2,7 +2,7 @@
"name": "trilium", "name": "trilium",
"productName": "Trilium Notes", "productName": "Trilium Notes",
"description": "Trilium Notes", "description": "Trilium Notes",
"version": "0.43.0-beta", "version": "0.43.3",
"license": "AGPL-3.0-only", "license": "AGPL-3.0-only",
"main": "electron.js", "main": "electron.js",
"bin": { "bin": {

View File

@ -328,6 +328,9 @@ function dynamicRequire(moduleName) {
} }
function timeLimit(promise, limitMs) { function timeLimit(promise, limitMs) {
// better stack trace if created outside of promise
const error = new Error('Process exceeded time limit ' + limitMs);
return new Promise((res, rej) => { return new Promise((res, rej) => {
let resolved = false; let resolved = false;
@ -339,7 +342,7 @@ function timeLimit(promise, limitMs) {
setTimeout(() => { setTimeout(() => {
if (!resolved) { if (!resolved) {
rej(new Error('Process exceeded time limit ' + limitMs)); rej(error);
} }
}, limitMs); }, limitMs);
}); });

View File

@ -49,7 +49,7 @@ function loginSync(req) {
return { return {
sourceId: sourceIdService.getCurrentSourceId(), sourceId: sourceIdService.getCurrentSourceId(),
maxSyncId: sql.getValue("SELECT MAX(id) FROM sync WHERE isSynced = 1") maxSyncId: sql.getValue("SELECT COALESCE(MAX(id), 0) FROM sync WHERE isSynced = 1")
}; };
} }

View File

@ -50,7 +50,7 @@ function getStats() {
function checkSync() { function checkSync() {
return { return {
entityHashes: contentHashService.getEntityHashes(), entityHashes: contentHashService.getEntityHashes(),
maxSyncId: sql.getValue('SELECT MAX(id) FROM sync WHERE isSynced = 1') maxSyncId: sql.getValue('SELECT COALESCE(MAX(id), 0) FROM sync WHERE isSynced = 1')
}; };
} }
@ -124,7 +124,7 @@ function getChanged(req) {
const ret = { const ret = {
syncs: syncService.getSyncRecords(syncs), syncs: syncService.getSyncRecords(syncs),
maxSyncId: sql.getValue('SELECT MAX(id) FROM sync WHERE isSynced = 1') maxSyncId: sql.getValue('SELECT COALESCE(MAX(id), 0) FROM sync WHERE isSynced = 1')
}; };
if (ret.syncs.length > 0) { if (ret.syncs.length > 0) {

View File

@ -23,7 +23,7 @@ function index(req, res) {
treeFontSize: parseInt(options.treeFontSize), treeFontSize: parseInt(options.treeFontSize),
detailFontSize: parseInt(options.detailFontSize), detailFontSize: parseInt(options.detailFontSize),
sourceId: sourceIdService.generateSourceId(), sourceId: sourceIdService.generateSourceId(),
maxSyncIdAtLoad: sql.getValue("SELECT MAX(id) FROM sync"), maxSyncIdAtLoad: sql.getValue("SELECT COALESCE(MAX(id), 0) FROM sync"),
instanceName: config.General ? config.General.instanceName : null, instanceName: config.General ? config.General.instanceName : null,
appCssNoteIds: getAppCssNoteIds(), appCssNoteIds: getAppCssNoteIds(),
isDev: env.isDev(), isDev: env.isDev(),

View File

@ -4,7 +4,7 @@ const build = require('./build');
const packageJson = require('../../package'); const packageJson = require('../../package');
const {TRILIUM_DATA_DIR} = require('./data_dir'); const {TRILIUM_DATA_DIR} = require('./data_dir');
const APP_DB_VERSION = 161; const APP_DB_VERSION = 162;
const SYNC_VERSION = 14; const SYNC_VERSION = 14;
const CLIPPER_PROTOCOL_VERSION = "1.0"; const CLIPPER_PROTOCOL_VERSION = "1.0";

View File

@ -1 +1 @@
module.exports = { buildDate:"2020-07-11T23:58:59+02:00", buildRevision: "08edc521e48ea7c6de96c19290134b6552844313" }; module.exports = { buildDate:"2020-07-31T23:34:05+02:00", buildRevision: "17d7ff3ff1bd50f272046864ca28e0ef407e24c9" };

View File

@ -123,7 +123,7 @@ async function doLogin() {
} }
async function pullSync(syncContext) { async function pullSync(syncContext) {
let appliedPulls = 0; let atLeastOnePullApplied = false;
while (true) { while (true) {
const lastSyncedPull = getLastSyncedPull(); const lastSyncedPull = getLastSyncedPull();
@ -150,10 +150,10 @@ async function pullSync(syncContext) {
sql.transactional(() => { sql.transactional(() => {
for (const {sync, entity} of rows) { for (const {sync, entity} of rows) {
if (!sourceIdService.isLocalSourceId(sync.sourceId)) { if (!sourceIdService.isLocalSourceId(sync.sourceId)) {
if (appliedPulls === 0 && sync.entity !== 'recent_notes') { // send only for first if (!atLeastOnePullApplied && sync.entity !== 'recent_notes') { // send only for first
ws.syncPullInProgress(); ws.syncPullInProgress();
appliedPulls++; atLeastOnePullApplied = true;
} }
syncUpdateService.updateEntity(sync, entity, syncContext.sourceId); syncUpdateService.updateEntity(sync, entity, syncContext.sourceId);
@ -165,10 +165,10 @@ async function pullSync(syncContext) {
setLastSyncedPull(rows[rows.length - 1].sync.id); setLastSyncedPull(rows[rows.length - 1].sync.id);
}); });
log.info(`Pulled ${rows.length} changes in ${pulledDate - startDate}ms from ${changesUri} and applied them in ${Date.now() - pulledDate}ms`); log.info(`Pulled ${rows.length} changes starting at syncId=${lastSyncedPull} in ${pulledDate - startDate}ms and applied them in ${Date.now() - pulledDate}ms, ${stats.outstandingPulls} outstanding pulls`);
} }
if (appliedPulls > 0) { if (atLeastOnePullApplied) {
ws.syncPullFinished(); ws.syncPullFinished();
} }
@ -368,7 +368,7 @@ function updatePushStats() {
} }
function getMaxSyncId() { function getMaxSyncId() {
return sql.getValue('SELECT MAX(id) FROM sync'); return sql.getValue('SELECT COALESCE(MAX(id), 0) FROM sync');
} }
sqlInit.dbReady.then(() => { sqlInit.dbReady.then(() => {

View File

@ -82,7 +82,8 @@ function fillSyncRows(entityName, entityPrimaryKey, condition = '') {
entityName: entityName, entityName: entityName,
entityId: entityId, entityId: entityId,
sourceId: "SYNC_FILL", sourceId: "SYNC_FILL",
utcSyncDate: dateUtils.utcNowDateTime() utcSyncDate: dateUtils.utcNowDateTime(),
isSynced: true
}); });
} }
} }