Skip to content

Commit ba7266d

Browse files
committed
Fix: sync edge case: matching timestamps, but different content lengths
1 parent a16eebd commit ba7266d

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

client/spaces/sync.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,23 @@ export class SpaceSync extends EventEmitter<SyncEvents> {
473473
await this.primary.deleteFile(path);
474474
snapshot.nonSyncedFiles.set(path, secondaryMeta);
475475
operations += 1;
476+
} else if (
477+
primaryMeta && secondaryMeta && snapshot.files.has(path) &&
478+
primaryMeta.size !== secondaryMeta.size
479+
) {
480+
// Sizes differ despite matching timestamps — silent content change
481+
// (e.g. file truncated without mtime update). Treat as conflict.
482+
console.warn(
483+
"[sync]",
484+
`Size mismatch despite matching timestamps (${primaryMeta.size} vs ${secondaryMeta.size} bytes), forcing conflict resolution:`,
485+
path,
486+
);
487+
operations += await this.options.conflictResolver(
488+
path,
489+
snapshot,
490+
this.primary,
491+
this.secondary,
492+
);
476493
} else {
477494
// Nothing needs to happen
478495
if (!syncBack && secondaryMeta) {

0 commit comments

Comments
 (0)