fix(documents): tighten archive/restore idempotency + document fire-and-forget
Three follow-ups from Task 6 code review: 1. applyEntityArchivedSuffix short-circuits when the folder is already archived — prevents archivedAt drift on backfill replay. 2. applyEntityRestoredSuffix short-circuits when the folder was never archived — matches the docstring's "no-op" claim. 3. Inline comment on archiveClient's fire-and-forget hook documents why Task 6 uses void (archive UI doesn't depend on folder sync) while Task 5 uses await (rename should be visible to the next read). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -600,6 +600,7 @@ export async function applyEntityArchivedSuffix(
|
||||
const newName = folder.name.endsWith(ARCHIVED_SUFFIX)
|
||||
? folder.name
|
||||
: `${folder.name}${ARCHIVED_SUFFIX}`;
|
||||
if (newName === folder.name && folder.archivedAt) return; // Already archived, no-op.
|
||||
await db
|
||||
.update(documentFolders)
|
||||
.set({ name: newName, archivedAt: new Date(), updatedAt: new Date() })
|
||||
@@ -628,6 +629,7 @@ export async function applyEntityRestoredSuffix(
|
||||
const newName = folder.name.endsWith(ARCHIVED_SUFFIX)
|
||||
? folder.name.slice(0, -ARCHIVED_SUFFIX.length)
|
||||
: folder.name;
|
||||
if (newName === folder.name && !folder.archivedAt) return; // Wasn't archived, no-op.
|
||||
await db
|
||||
.update(documentFolders)
|
||||
.set({ name: newName, archivedAt: null, updatedAt: new Date() })
|
||||
|
||||
Reference in New Issue
Block a user