You need to sign in or sign up before continuing.
Determine if an upload is referenced by an issue or merge request.
To implement Manage Discussion Storage and/or Attachment Manager, we need to determine if an upload is being referenced by an issue.
Problem
There is no direct way to track images that are not being referenced on issues or merge request. Consider the following example:
- User creates a new issue
- User attach file
picture_1.png
on the issue description- GitLab process
picture_1.png
and stores it.
- GitLab process
- User realizes it was the wrong file and removes the markdown tags from the issue description
- User uploads file
picture_2.png
- Gitlab process
picture_2.png
and stores it.
- Gitlab process
- User saves the issue.
GitLab ends up with two pictures, one of them not being used anywhere.
Proposal
Have a column that stores if an upload is being referenced or not
upload = project.uploads.last
upload.referenced?
=> true # upload appears on an issue or a merge request
Technical details (wip)
- Add a column on
uploads
- Add a background migration to populate
uploads
- Add an async job that verifies if an upload is referenced by an issue or a merge request.
Downsides
- Records to be updated by the background migration will be quite large.
Edited by 🤖 GitLab Bot 🤖