Uploads remain in the db after removing them from issue comment
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Problem
A customer asked the following question:
Wondering if we delete an image from an issue comment, if the image is deleted?
I looked into it on my 13.3.1-ee test instance and found that the images are kept even after they're removed from the issue.
Expected Behavior
File uploads should be removed from the database and from disk when removed from the issue.
Reproduction
Using GitLab 13.3.1-ee without any custom object storage configuration, I ran the following:
-
Create an issue in a project and add two comments, each with an image. Save them.
-
In the rails console, confirm that the project has two file uploads:
irb(main):102:0> project.uploads.count => 2 -
In the UI, edit the first comment to remove the image.
-
Also in the UI, remove the second comment altogether using the dropdown at its top right.
-
Confirm the changes work as expected in the UI. One image is deleted and another comment is deleted. One comment remains and no images remain.
-
Look in the rails console to see that both images still exist, even though they've been removed from the UI:
irb(main):112:0> project.reload => #<Project id:26 group-a/test>> irb(main):113:0> project.uploads.count => 2
They also still exist on disk.
I couldn't find any worker that removed these uploads async, so this seems like a bug. The rake task doesn't seem to apply since the files are still stored in the database.