From 4e88fc9211a90eb9362d90944bf846d1fbdbc608 Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Sat, 22 Nov 2025 21:08:16 +0000 Subject: [PATCH] Handle move on create --- .../src/sync-operations/unrestricted-syncer.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/frontend/sync-client/src/sync-operations/unrestricted-syncer.ts b/frontend/sync-client/src/sync-operations/unrestricted-syncer.ts index daffe4bf..b8bf7682 100644 --- a/frontend/sync-client/src/sync-operations/unrestricted-syncer.ts +++ b/frontend/sync-client/src/sync-operations/unrestricted-syncer.ts @@ -79,9 +79,10 @@ export class UnrestrictedSyncer { ); // this can throw FileNotFoundError const contentHash = hash(contentBytes); + const originalRelativePath = document.relativePath; const response = await this.syncService.create({ documentId: document.documentId, - relativePath: document.relativePath, + relativePath: originalRelativePath, contentBytes }); @@ -93,6 +94,15 @@ export class UnrestrictedSyncer { }, document ); + + // In case a document with the same name (but different ID) had existed remotely that we haven't known about + if (response.relativePath != originalRelativePath) { + await this.operations.move( + document.relativePath, + response.relativePath + ); // this can throw FileNotFoundError + } + this.database.addSeenUpdateId(response.vaultUpdateId); this.updateCache( response.vaultUpdateId,