Skip to content

WardrobeRepository.cs: Stale image cleanup index after partial write in SetDraftTerminalAsync #98

@AB-Law

Description

@AB-Law

Problem

PluckIt.Infrastructure/WardrobeRepository.cs:387-405 patches the wardrobe item first, then calls SyncImageCleanupIndexAsync. If the second call fails, the item is updated but the cleanup index is stale — orphaned image URLs will never be collected.

await _container.PatchItemAsync(...);                          // Step 1: succeeds
await SyncImageCleanupIndexAsync(response.Resource, ct);      // Step 2: can fail silently
return true;

Impact

Orphaned blobs accumulate in Azure Storage; the daily cleanup misses them; storage costs grow unbounded.

Proposed Fix

Wrap SyncImageCleanupIndexAsync in a try/catch that logs a warning on failure, and introduce a background reconciliation sweep (e.g., via change feed) to detect and fix stale index entries.

Functionality Impact

No functional change for users; improves cleanup reliability and reduces storage costs over time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions