Agent Wranglers

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

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.