Clean up orphaned uploads of deleted personal snippets
We should add a migration to clean up uploads and their files that were orphaned before PersonalSnippet
included WithUploads
.
- An orphaned upload thinks its file does not exist, because the
PersonalFileUploader
thinks the file is in temp since itsmodel
, theSnippet
, does not exist. But themodel_id
is still set, so we can find where the upload file actually is, so we can clean up the files with a migration. - This is not necessary pre GCP migration
- Ideally, we need to clean up files on Geo secondaries first, before deleting the uploads records
Please ignore the rest of the description, kept as history.
This is a source of "missing on primary" files, which slows research into truly missing files as part of GCP Migration: https://gitlab.com/gitlab-com/migration/issues/465
Snippet
model is missinghas_many :uploads, as: :model, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
Edit:
WithUploads
has since been included inPersonalSnippet
, which effectively does this. And it should not be included in superclassSnippet
sinceProjectSnippet
should not have it. Those uploads are associated directly withProject
.
Edited by Michael Kozono