diff options
author | Douwe Maan <douwe@gitlab.com> | 2017-11-14 12:48:19 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2017-11-14 12:48:19 +0300 |
commit | c9515ca541ebaa3ce0a3208ab08eb59c580cbed6 (patch) | |
tree | 940a4de00c36470ae7910fd7e15dd0338c2d6472 /app | |
parent | 58bd04ab75d99fa9be0d9568c442704d400e8b1d (diff) | |
parent | ebd51744729cb1b68754f8ba4d7f9adcec28d58d (diff) |
Merge branch 'jej/fix-lfs-integrity-with-forks' into 'master'
Handle forks in Gitlab::Checks::LfsIntegrity
Closes #39902
See merge request gitlab-org/gitlab-ce!15279
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/concerns/lfs_request.rb | 10 | ||||
-rw-r--r-- | app/models/lfs_object.rb | 10 | ||||
-rw-r--r-- | app/models/project.rb | 12 |
3 files changed, 14 insertions, 18 deletions
diff --git a/app/controllers/concerns/lfs_request.rb b/app/controllers/concerns/lfs_request.rb index 6cca9f95618..4311f9d4db9 100644 --- a/app/controllers/concerns/lfs_request.rb +++ b/app/controllers/concerns/lfs_request.rb @@ -92,15 +92,7 @@ module LfsRequest end def storage_project - @storage_project ||= begin - result = project - - # TODO: Make this go to the fork_network root immeadiatly - # dependant on the discussion in: https://gitlab.com/gitlab-org/gitlab-ce/issues/39769 - result = result.fork_source while result.forked? - - result - end + @storage_project ||= project.lfs_storage_project end def objects diff --git a/app/models/lfs_object.rb b/app/models/lfs_object.rb index b7cf96abe83..fc586fa216e 100644 --- a/app/models/lfs_object.rb +++ b/app/models/lfs_object.rb @@ -6,16 +6,8 @@ class LfsObject < ActiveRecord::Base mount_uploader :file, LfsObjectUploader - def storage_project(project) - if project && project.forked? - storage_project(project.forked_from_project) - else - project - end - end - def project_allowed_access?(project) - projects.exists?(storage_project(project).id) + projects.exists?(project.lfs_storage_project.id) end def self.destroy_unreferenced diff --git a/app/models/project.rb b/app/models/project.rb index bae16b6b2af..853f6bc504a 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1047,6 +1047,18 @@ class Project < ActiveRecord::Base forked_from_project || fork_network&.root_project end + def lfs_storage_project + @lfs_storage_project ||= begin + result = self + + # TODO: Make this go to the fork_network root immeadiatly + # dependant on the discussion in: https://gitlab.com/gitlab-org/gitlab-ce/issues/39769 + result = result.fork_source while result&.forked? + + result || self + end + end + def personal? !group end |