Delete cached S3 file on destroy

As the title suggests, I’ve upgraded to Shrine 3 and have moved to direct-to-S3 uploads. In doing so, I’ve noticed that destroying a record whose file is in cache (where the cache storage is S3) does not delete the remote S3 file. Is there a way to do this?

If the cached file is still attached when the record is destroyed, it doesn’t get deleted because there might be a background job that’s promoting the file to permanent storage or using it for processing. So, to prevent background jobs for raising errors that the file is missing, we avoid deleting cached files.

Note that cached files need to be deleted separately anyway, as instructed in the “Clearing cache” section.

Got it. That makes sense. Thank you!