简体   繁体   中英

Active Storage - Abandoned Files

I've messed up and used the same bucket for storage with my development and production environment. My question is what happens if the hash that is created for the file name in production overlaps a hash that was created in development? Is there any check for this? Is there anyway to clean up the abandoned files?

Thanks :)

Blob keys are generated using SecureRandom (rails' has_secure_token ), so it is very unlikely that some file got overwritten. To be completely sure - check for duplicate keys in active_storage_blobs , to do that I'd dump that table from production and import it on development under different table name and then join ed two tables, if everything is ok - there'll be empty intersection.

Next step is cleanup (actually if there's not that much data from development - it may be cheaper just to forget). For that you'll have to write a script that lists your bucket(that depends on you storage service) and finds these abandoned files - from filename you can reconstruct the key for the blob and then check if that key belongs to production.

Just be sure to double-check that list - there may false positives - files that were just uploaded and not yet written to db.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM