How to find all variations of an unpurged orphaned image in a S3 bucket?

So I’m having an issue with removing an upload image.

The upload seems to not exist in the database, at least from the searches I’ve tried. Which are:

rails:

Upload.find_by_sha1('39b0c58d2d462e6c88d684344a8dd1f09da1ba47')

postgres:

select * from uploads where sha1 like '39b0c58d2d462e6c88d684344a8dd1f09da1ba47';

With the hash being from the image url (hash above is an example only). I can normally find the images with these and usually find where the image was used first. But I haven’t had this case before, in which the upload seems to not exist, yet exists in the bucket.

So I’m not sure how this happened.

I checked inside the bucket and see the image file there from 2 years ago.

So I’m thinking I’ll need to manually find them by navigating the bucket. I’m wondering if there is a way to know what the paths of the optimized files are if you have the original url without database records? Or perhaps there are other queries that might bring results?

The path is like: /original/2X/f/39b0c58d2d462e6c88d684344a8dd1f09da1ba47.jpg

I see in Scaleway that there the purge_tombstone policy exists and is enabled. I have ‘purge deleted uploads grace period days’ set to 1 day in Discourse.

Have you had any luck figuring this out @markersocial? :crossed_fingers:

Hi @JammyDodger - unfortunately no, all I could do was remove the single image from the bucket manually and hope there weren’t any optimised versions.

1 Like