Skip to content

STE-113: Fix shared-content deletion bug in attachment storage - #32

Merged
aggieben merged 1 commit into
masterfrom
ste-113/fix-shared-content-deletion-v2
May 1, 2026
Merged

aggieben merged 1 commit into
masterfrom
ste-113/fix-shared-content-deletion-v2

Conversation

@aggieben

@aggieben aggieben commented May 1, 2026

Copy link
Copy Markdown
Member

Fixes the attachment storage bug where deleting one attachment that shares a content-addressed file with another leaves the second with a dangling reference.

Changes:

  • AttachmentRepository: added CountByStorageRefAsync for ref-counting within tenant scope
  • AttachmentEndpoints: fixed deleteAttachmentHandler to delete row first, count refs, then conditionally delete file
  • AttachmentResponse: added storageRef field for API completeness
  • New endpoint and repository tests covering the bug

Also fixes pre-existing master build issues (merge conflict markers, missing DeletedAt fields, stray userId argument).

…Endpoints, add CountByStorageRefAsync

- Fixed deleteAttachmentHandler to delete DB row first, then
  CountByStorageRefAsync, then conditionally delete the file.
- Added AttachmentResponse.storageRef to enable test assertions.
- Added CountByStorageRefAsync to IAttachmentRepository and
  AttachmentRepository (tenant-scoped, RLS-aware).
- New endpoint test: shared file survives deletion of duplicate
  attachment referencing same storage_ref.
- New repository test: CountByStorageRefAsync returns correct
  counts before/after deletions.
- Fixed pre-existing master issues:
  - TransferEndpoints: missing DeletedAt field on Transaction records
  - ReconciliationEndpointsTests: extra userId argument typo
  - Program.fs: leftover conflict markers from STE-25 merge

Co-Authored-By: Paperclip <noreply@paperclip.ing>
@aggieben
aggieben merged commit 2fe8ec3 into master May 1, 2026
1 check failed
@aggieben
aggieben deleted the ste-113/fix-shared-content-deletion-v2 branch May 1, 2026 02:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants