// Workspace's default namespace stores R2 objects under /default/. // Delete the facet first, then its objects, without waking the child during // parent startup recovery (the child's initialization can call the parent). export async function deleteConversationAttachmentObjects( bucket: R2Bucket | undefined, conversationId: string, ): Promise { if (!bucket) return; const prefix = `${conversationId}/default/attachments/`; let cursor: string | undefined; do { const page = await bucket.list({ prefix, cursor }); if (page.objects.length) await bucket.delete(page.objects.map((o) => o.key)); cursor = page.truncated ? page.cursor : undefined; } while (cursor); }