Handle move on create

This commit is contained in:
Andras Schmelczer 2025-11-22 21:08:16 +00:00
parent c5ee8e1cd7
commit 4e88fc9211

View file

@ -79,9 +79,10 @@ export class UnrestrictedSyncer {
); // this can throw FileNotFoundError ); // this can throw FileNotFoundError
const contentHash = hash(contentBytes); const contentHash = hash(contentBytes);
const originalRelativePath = document.relativePath;
const response = await this.syncService.create({ const response = await this.syncService.create({
documentId: document.documentId, documentId: document.documentId,
relativePath: document.relativePath, relativePath: originalRelativePath,
contentBytes contentBytes
}); });
@ -93,6 +94,15 @@ export class UnrestrictedSyncer {
}, },
document 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.database.addSeenUpdateId(response.vaultUpdateId);
this.updateCache( this.updateCache(
response.vaultUpdateId, response.vaultUpdateId,