mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
small fixes
This commit is contained in:
parent
5e3538669d
commit
5bba18191f
@ -91,6 +91,7 @@ app.use((err, req, res, next) => {
|
|||||||
if (err && err.message && (
|
if (err && err.message && (
|
||||||
err.message.includes("Invalid package")
|
err.message.includes("Invalid package")
|
||||||
|| (err.message.includes("Router not found for request") && err.message.includes("node_modules"))
|
|| (err.message.includes("Router not found for request") && err.message.includes("node_modules"))
|
||||||
|
|| (err.message.includes("Router not found for request") && err.message.includes(".js.map"))
|
||||||
)) {
|
)) {
|
||||||
// electron 6 outputs a lot of such errors which do not seem important
|
// electron 6 outputs a lot of such errors which do not seem important
|
||||||
}
|
}
|
||||||
|
@ -47,14 +47,15 @@ async function handleMessage(event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (message.type === 'sync') {
|
if (message.type === 'sync') {
|
||||||
|
const syncRows = message.data;
|
||||||
lastPingTs = Date.now();
|
lastPingTs = Date.now();
|
||||||
|
|
||||||
$outstandingSyncsCount.html(message.outstandingSyncs);
|
$outstandingSyncsCount.html(message.outstandingSyncs);
|
||||||
|
|
||||||
if (message.data.length > 0) {
|
if (syncRows.length > 0) {
|
||||||
console.debug(utils.now(), "Sync data: ", message.data);
|
console.debug(utils.now(), "Sync data: ", syncRows);
|
||||||
|
|
||||||
syncDataQueue.push(...message.data);
|
syncDataQueue.push(...syncRows);
|
||||||
|
|
||||||
// first wait for all the preceding consumers to finish
|
// first wait for all the preceding consumers to finish
|
||||||
while (consumeQueuePromise) {
|
while (consumeQueuePromise) {
|
||||||
@ -69,6 +70,8 @@ async function handleMessage(event) {
|
|||||||
// finish and set to null to signal somebody else can pick it up
|
// finish and set to null to signal somebody else can pick it up
|
||||||
consumeQueuePromise = null;
|
consumeQueuePromise = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkSyncIdListeners();
|
||||||
}
|
}
|
||||||
else if (message.type === 'sync-hash-check-failed') {
|
else if (message.type === 'sync-hash-check-failed') {
|
||||||
toastService.showError("Sync check failed!", 60000);
|
toastService.showError("Sync check failed!", 60000);
|
||||||
@ -94,6 +97,18 @@ function waitForSyncId(desiredSyncId) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkSyncIdListeners() {
|
||||||
|
syncIdReachedListeners
|
||||||
|
.filter(l => l.desiredSyncId <= lastSyncId)
|
||||||
|
.forEach(l => l.resolvePromise());
|
||||||
|
|
||||||
|
syncIdReachedListeners = syncIdReachedListeners
|
||||||
|
.filter(l => l.desiredSyncId > lastSyncId);
|
||||||
|
|
||||||
|
syncIdReachedListeners.filter(l => Date.now() > l.start - 60000)
|
||||||
|
.forEach(l => console.log(`Waiting for syncId ${l.desiredSyncId} while current is ${lastSyncId} for ${Date.now() - l.start}`));
|
||||||
|
}
|
||||||
|
|
||||||
async function consumeSyncData() {
|
async function consumeSyncData() {
|
||||||
if (syncDataQueue.length >= 0) {
|
if (syncDataQueue.length >= 0) {
|
||||||
const allSyncData = syncDataQueue;
|
const allSyncData = syncDataQueue;
|
||||||
@ -109,16 +124,6 @@ async function consumeSyncData() {
|
|||||||
|
|
||||||
lastSyncId = allSyncData[allSyncData.length - 1].id;
|
lastSyncId = allSyncData[allSyncData.length - 1].id;
|
||||||
}
|
}
|
||||||
|
|
||||||
syncIdReachedListeners
|
|
||||||
.filter(l => l.desiredSyncId <= lastSyncId)
|
|
||||||
.forEach(l => l.resolvePromise());
|
|
||||||
|
|
||||||
syncIdReachedListeners = syncIdReachedListeners
|
|
||||||
.filter(l => l.desiredSyncId > lastSyncId);
|
|
||||||
|
|
||||||
syncIdReachedListeners.filter(l => Date.now() > l.start - 60000)
|
|
||||||
.forEach(l => console.log(`Waiting for syncId ${l.desiredSyncId} for ${Date.now() - l.start}`));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function connectWebSocket() {
|
function connectWebSocket() {
|
||||||
@ -167,8 +172,7 @@ subscribeToMessages(message => {
|
|||||||
icon: "refresh"
|
icon: "refresh"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
else if (message.type === 'sync-pull-finished') {
|
||||||
if (message.type === 'sync-pull-finished') {
|
|
||||||
toastService.closePersistent('sync');
|
toastService.closePersistent('sync');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -147,7 +147,6 @@ async function pullSync(syncContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stats.outstandingPulls = resp.maxSyncId - sync.id;
|
stats.outstandingPulls = resp.maxSyncId - sync.id;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await setLastSyncedPull(rows[rows.length - 1].sync.id);
|
await setLastSyncedPull(rows[rows.length - 1].sync.id);
|
||||||
|
@ -103,7 +103,7 @@ function syncPullInProgress() {
|
|||||||
sendMessageToAllClients({ type: 'sync-pull-in-progress' });
|
sendMessageToAllClients({ type: 'sync-pull-in-progress' });
|
||||||
}
|
}
|
||||||
|
|
||||||
async function syncPullFinished() {
|
function syncPullFinished() {
|
||||||
sendMessageToAllClients({ type: 'sync-pull-finished' });
|
sendMessageToAllClients({ type: 'sync-pull-finished' });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user