MED-49Required
Delete files when their owner is deleted
Record every stored object in a files table with its owner, and delete the objects in the same job that deletes the owner.
How to do it
Make the delete job remove objects first, then rows, so a crash leaves rows to retry rather than unknown objects. On versioned buckets delete every version, or the file lives on. Include derived files, such as thumbnails and rebuilt images. Run a weekly sweep that lists the bucket and compares it with the table. Delete objects with no row that are older than 7 days. Deleting the owner, or an erasure request, skips the bin from Keep deleted files restorable for 30 days. A single file a person deletes waits out that bin first. Backup copies age out as Keep backups for a set time sets. Write all three periods into one retention schedule, so the deletion jobs read the same numbers. The request side and time limits are in let people see and delete their data.
How to check
Create a test owner with an upload, a thumbnail and two versions of a file. Delete the owner. A listing of the owner's prefix, including old versions, is empty. The weekly sweep reports zero objects without a row.
Sources
Related rules
- DAT-72 Delete every copy of a tenant when the contract ends in Data and databases
- MED-4 Keep deleted files restorable for 30 days in Files and media
- MED-6 Restore files and their records together in Files and media
- MED-48 Store the same file once per owner in Files and media
- OPS-46 Keep backups for a set time in Operations and observability
- CMP-11 Keep one retention schedule in Compliance and governance
- WEB-217 Let people see and delete their data in Website
- MED-21 Purge cached copies when a file is deleted or removed in Files and media
- MED-35 Record who uploaded each file and under what licence in Files and media
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/files-and-media/storage-and-backups/delete-files-with-owner">Agent Wranglers files and media playbook</a>. In code you write, add a comment next to it with the same link.