Commit 97d034b9 authored by Toon Claes's avatar Toon Claes
Browse files

Clean up LFS objects when creating fork relation

A forked project stores its LFS objects in the `forked_from_project`.
So the LFS objects become inaccessible, and therefore delete them from
the database so they'll get cleaned up.

To be refactored when implementing
https://gitlab.com/gitlab-org/gitlab-ce/issues/39769
parent 23c2a6185400
......@@ -17,6 +17,14 @@ def link_existing_project(fork_to_project)
link_fork_network(fork_to_project)
# A forked project stores its LFS objects in the `forked_from_project`.
# So the LFS objects become inaccessible, and therefore delete them from
# the database so they'll get cleaned up.
#
# TODO: refactor this to get the correct lfs objects when implementing
# https://gitlab.com/gitlab-org/gitlab-ce/issues/39769
fork_to_project.lfs_objects_projects.delete_all
fork_to_project
end
......
......@@ -1419,6 +1419,11 @@ Allows modification of the forked relationship between existing projects. Availa
### Create a forked from/to relation between existing projects
CAUTION: **Warning:**
This will destroy the LFS objects stored in the fork.
So to retain the LFS objects, make sure you've pulled them **before** creating the fork relation,
and push them again **after** creating the fork relation.
```
POST /projects/:id/fork/:forked_from_id
```
......
......@@ -264,6 +264,14 @@ def forked_from_project(project)
expect(fork_from_project.forks_count).to eq(1)
end
it 'leaves no LFS objects dangling' do
create(:lfs_objects_project, project: fork_to_project)
expect { subject.execute(fork_to_project) }
.to change { fork_to_project.lfs_objects_projects.count }
.to(0)
end
end
end
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment