Sync tweaks
parent
e7728c2d2a
commit
c56caac533
|
@ -65,15 +65,19 @@ export class SpaceSync {
|
||||||
|
|
||||||
this.logger.log("info", "Iterating over all files");
|
this.logger.log("info", "Iterating over all files");
|
||||||
for (const name of allFilesToProcess) {
|
for (const name of allFilesToProcess) {
|
||||||
operations += await this.syncFile(
|
try {
|
||||||
name,
|
operations += await this.syncFile(
|
||||||
primaryFileMap.get(name),
|
name,
|
||||||
secondaryFileMap.get(name),
|
primaryFileMap.get(name),
|
||||||
conflictResolver,
|
secondaryFileMap.get(name),
|
||||||
);
|
conflictResolver,
|
||||||
|
);
|
||||||
|
} catch (e: any) {
|
||||||
|
this.logger.log("error", "Error syncing file", name, e.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
this.logger.log("error", "Sync error:", e.message);
|
this.logger.log("error", "General sync error:", e.message);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
this.logger.log("info", "Sync complete, operations performed", operations);
|
this.logger.log("info", "Sync complete, operations performed", operations);
|
||||||
|
@ -206,6 +210,11 @@ export class SpaceSync {
|
||||||
primaryHash === this.snapshot.get(name)![0]
|
primaryHash === this.snapshot.get(name)![0]
|
||||||
) {
|
) {
|
||||||
// File has changed on secondary, but not primary: copy from secondary to primary
|
// 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 { data } = await this.secondary.readFile(name, "arraybuffer");
|
||||||
const writtenMeta = await this.primary.writeFile(
|
const writtenMeta = await this.primary.writeFile(
|
||||||
name,
|
name,
|
||||||
|
|
|
@ -119,8 +119,8 @@ export function check(config: SyncEndpoint) {
|
||||||
return sync.check(config);
|
return sync.check(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
// const syncTimeout = 1000 * 60 * 30; // 30 minutes
|
const syncTimeout = 1000 * 60 * 10; // 10 minutes
|
||||||
const syncTimeout = 1000 * 20; // 20s
|
// const syncTimeout = 1000 * 20; // 20s
|
||||||
|
|
||||||
// Run on server
|
// Run on server
|
||||||
export async function performSync() {
|
export async function performSync() {
|
||||||
|
|
Loading…
Reference in New Issue