From c56caac533138f3d16588ec7d208d401454662b1 Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Wed, 25 Jan 2023 09:46:56 +0100 Subject: [PATCH] Sync tweaks --- common/spaces/sync.ts | 23 ++++++++++++++++------- plugs/sync/sync.ts | 4 ++-- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/common/spaces/sync.ts b/common/spaces/sync.ts index 923bb98..31d327c 100644 --- a/common/spaces/sync.ts +++ b/common/spaces/sync.ts @@ -65,15 +65,19 @@ export class SpaceSync { this.logger.log("info", "Iterating over all files"); for (const name of allFilesToProcess) { - operations += await this.syncFile( - name, - primaryFileMap.get(name), - secondaryFileMap.get(name), - conflictResolver, - ); + try { + operations += await this.syncFile( + name, + primaryFileMap.get(name), + secondaryFileMap.get(name), + conflictResolver, + ); + } catch (e: any) { + this.logger.log("error", "Error syncing file", name, e.message); + } } } catch (e: any) { - this.logger.log("error", "Sync error:", e.message); + this.logger.log("error", "General sync error:", e.message); throw e; } this.logger.log("info", "Sync complete, operations performed", operations); @@ -206,6 +210,11 @@ export class SpaceSync { primaryHash === this.snapshot.get(name)![0] ) { // File has changed on secondary, but not primary: copy from secondary to primary + this.logger.log( + "info", + "File has changed on secondary, but not primary: copy from secondary to primary", + name, + ); const { data } = await this.secondary.readFile(name, "arraybuffer"); const writtenMeta = await this.primary.writeFile( name, diff --git a/plugs/sync/sync.ts b/plugs/sync/sync.ts index d336093..03e9eea 100644 --- a/plugs/sync/sync.ts +++ b/plugs/sync/sync.ts @@ -119,8 +119,8 @@ export function check(config: SyncEndpoint) { return sync.check(config); } -// const syncTimeout = 1000 * 60 * 30; // 30 minutes -const syncTimeout = 1000 * 20; // 20s +const syncTimeout = 1000 * 60 * 10; // 10 minutes +// const syncTimeout = 1000 * 20; // 20s // Run on server export async function performSync() {