Skip to content

fix: storage write failures and orphaned blob cleanup#40

Open
careck wants to merge 3 commits intomainfrom
fix/storage-write-failures-and-orphaned-blobs
Open

fix: storage write failures and orphaned blob cleanup#40
careck wants to merge 3 commits intomainfrom
fix/storage-write-failures-and-orphaned-blobs

Conversation

@careck
Copy link
Copy Markdown
Member

@careck careck commented May 1, 2026

Summary

  • StorageService::store() now checks mkdir() and file_put_contents() return values, throwing RuntimeException on failure instead of silently returning a phantom path (closes C3: Storage write failures are silently ignored #6)
  • BundleRoutingService::routeBundle() wraps the DB insert + storage-usage update in a PDO transaction; on failure, rolls back and deletes the orphaned blob from disk (closes C4: Orphaned blobs on routing/DB failure #7)
  • CreateInviteHandler wraps the invite DB insert in a try/catch that deletes the blob on failure (closes C4: Orphaned blobs on routing/DB failure #7)
  • Docker dev environment added — docker compose up starts the relay at localhost:8080, docker compose run test runs PHPUnit

Test plan

  • All 118 existing tests pass locally
  • All 118 tests pass in Docker (docker compose run test)
  • Dev server starts and responds in Docker (docker compose up)
  • Verify storage write failure by making storage/bundles/ read-only and confirming a RuntimeException is thrown on upload
  • Verify orphaned blob cleanup by simulating a DB failure after blob write and confirming no .swarm file is left behind

careck added 3 commits May 1, 2026 18:01
…, closes #7)

StorageService::store() now throws RuntimeException when mkdir() or
file_put_contents() fails, preventing silent data loss.

BundleRoutingService::routeBundle() wraps DB insert + storage-usage
update in a transaction and deletes the blob on failure.
CreateInviteHandler does the same for invite blob writes.
Dockerfile (multi-stage), docker-compose.yml, and entrypoint script.
`docker compose up` starts the relay at localhost:8080 with auto-init.
`docker compose run test` runs PHPUnit with dev dependencies.
Remove the base_url setting from config/settings.php and derive it
from the PSR-7 request URI in all three invite handlers. This makes
invite URLs correct in any environment without configuration.
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.

C4: Orphaned blobs on routing/DB failure C3: Storage write failures are silently ignored

1 participant