mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
better reporting of sync error when "sync now"
This commit is contained in:
parent
b64ef6311c
commit
68c2edea45
@ -8,12 +8,16 @@ function syncNow() {
|
|||||||
if (result.success) {
|
if (result.success) {
|
||||||
status.checkStatus();
|
status.checkStatus();
|
||||||
|
|
||||||
message("Sync triggered.");
|
message("Sync finished successfully.");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
error("Sync failed");
|
if (result.message.length > 50) {
|
||||||
|
result.message = result.message.substr(0, 50);
|
||||||
|
}
|
||||||
|
|
||||||
|
error("Sync failed: " + result.message);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: () => error("Sync failed")
|
error: () => error("Sync failed for unknown reason.")
|
||||||
});
|
});
|
||||||
}
|
}
|
@ -8,11 +8,7 @@ const sql = require('../../services/sql');
|
|||||||
const options = require('../../services/options');
|
const options = require('../../services/options');
|
||||||
|
|
||||||
router.post('/now', auth.checkApiAuth, async (req, res, next) => {
|
router.post('/now', auth.checkApiAuth, async (req, res, next) => {
|
||||||
await sync.sync();
|
res.send(await sync.sync());
|
||||||
|
|
||||||
res.send({
|
|
||||||
success: true
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get('/changed', auth.checkApiAuth, async (req, res, next) => {
|
router.get('/changed', auth.checkApiAuth, async (req, res, next) => {
|
||||||
|
@ -195,7 +195,10 @@ async function sync() {
|
|||||||
if (syncInProgress) {
|
if (syncInProgress) {
|
||||||
logSyncError("Sync already in progress");
|
logSyncError("Sync already in progress");
|
||||||
|
|
||||||
return;
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "Sync already in progress"
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
syncInProgress = true;
|
syncInProgress = true;
|
||||||
@ -204,7 +207,10 @@ async function sync() {
|
|||||||
if (!await migration.isDbUpToDate()) {
|
if (!await migration.isDbUpToDate()) {
|
||||||
logSyncError("DB not up to date");
|
logSyncError("DB not up to date");
|
||||||
|
|
||||||
return;
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "DB not up to date"
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const syncContext = await login();
|
const syncContext = await login();
|
||||||
@ -214,9 +220,18 @@ async function sync() {
|
|||||||
await pullSync(syncContext);
|
await pullSync(syncContext);
|
||||||
|
|
||||||
await pushSync(syncContext);
|
await pushSync(syncContext);
|
||||||
|
|
||||||
|
return {
|
||||||
|
success: true
|
||||||
|
};
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
logSync("sync failed: " + e.stack);
|
logSync("sync failed: " + e.stack);
|
||||||
|
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: e.message
|
||||||
|
}
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
syncInProgress = false;
|
syncInProgress = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user