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