mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
non-intrusive logging of sync errors
This commit is contained in:
parent
bf073690e0
commit
f0b608ddec
@ -99,15 +99,12 @@ if (!fs.existsSync(dataDir.BACKUP_DIR)) {
|
|||||||
fs.mkdirSync(dataDir.BACKUP_DIR, 0o700);
|
fs.mkdirSync(dataDir.BACKUP_DIR, 0o700);
|
||||||
}
|
}
|
||||||
|
|
||||||
// hack
|
sqlInit.dbReady.then(() => {
|
||||||
setTimeout(() => {
|
setInterval(cls.wrap(regularBackup), 4 * 60 * 60 * 1000);
|
||||||
sqlInit.dbReady.then(() => {
|
|
||||||
setInterval(cls.wrap(regularBackup), 4 * 60 * 60 * 1000);
|
|
||||||
|
|
||||||
// kickoff first backup soon after start up
|
// kickoff first backup soon after start up
|
||||||
setTimeout(cls.wrap(regularBackup), 5 * 60 * 1000);
|
setTimeout(cls.wrap(regularBackup), 5 * 60 * 1000);
|
||||||
});
|
});
|
||||||
}, 5000);
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
backupNow,
|
backupNow,
|
||||||
|
@ -2,6 +2,7 @@ const utils = require('./utils');
|
|||||||
const dateUtils = require('./date_utils');
|
const dateUtils = require('./date_utils');
|
||||||
const log = require('./log');
|
const log = require('./log');
|
||||||
const sql = require('./sql');
|
const sql = require('./sql');
|
||||||
|
const sqlInit = require('./sql_init');
|
||||||
const cls = require('./cls');
|
const cls = require('./cls');
|
||||||
|
|
||||||
function saveSourceId(sourceId) {
|
function saveSourceId(sourceId) {
|
||||||
@ -46,12 +47,7 @@ function isLocalSourceId(srcId) {
|
|||||||
|
|
||||||
const currentSourceId = createSourceId();
|
const currentSourceId = createSourceId();
|
||||||
|
|
||||||
// very ugly
|
sqlInit.dbReady.then(cls.wrap(() => saveSourceId(currentSourceId)));
|
||||||
setTimeout(() => {
|
|
||||||
const sqlInit = require('./sql_init');
|
|
||||||
|
|
||||||
sqlInit.dbReady.then(cls.wrap(() => saveSourceId(currentSourceId)));
|
|
||||||
}, 5000);
|
|
||||||
|
|
||||||
function getCurrentSourceId() {
|
function getCurrentSourceId() {
|
||||||
return currentSourceId;
|
return currentSourceId;
|
||||||
|
@ -87,7 +87,7 @@ async function login() {
|
|||||||
await setupService.sendSeedToSyncServer();
|
await setupService.sendSeedToSyncServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
return doLogin();
|
return await doLogin();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function doLogin() {
|
async function doLogin() {
|
||||||
@ -257,7 +257,7 @@ async function checkContentHash(syncContext) {
|
|||||||
return failedChecks.length > 0;
|
return failedChecks.length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function syncRequest(syncContext, method, requestPath, body) {
|
async function syncRequest(syncContext, method, requestPath, body) {
|
||||||
const timeout = syncOptions.getSyncTimeout();
|
const timeout = syncOptions.getSyncTimeout();
|
||||||
|
|
||||||
const opts = {
|
const opts = {
|
||||||
@ -269,7 +269,7 @@ function syncRequest(syncContext, method, requestPath, body) {
|
|||||||
proxy: proxyToggle ? syncOptions.getSyncProxy() : null
|
proxy: proxyToggle ? syncOptions.getSyncProxy() : null
|
||||||
};
|
};
|
||||||
|
|
||||||
return utils.timeLimit(request.exec(opts), timeout);
|
return await utils.timeLimit(request.exec(opts), timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
const primaryKeys = {
|
const primaryKeys = {
|
||||||
|
@ -10,7 +10,7 @@ async function doExclusively(func) {
|
|||||||
const releaseMutex = await instance.acquire();
|
const releaseMutex = await instance.acquire();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return func();
|
return await func();
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
releaseMutex();
|
releaseMutex();
|
||||||
|
@ -244,7 +244,8 @@ function timeLimit(promise, limitMs) {
|
|||||||
resolved = true;
|
resolved = true;
|
||||||
|
|
||||||
res(result);
|
res(result);
|
||||||
});
|
})
|
||||||
|
.catch(error => rej(error));
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!resolved) {
|
if (!resolved) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user