diff options
author | Michael Kozono <mkozono@gmail.com> | 2018-03-13 15:04:00 -0700 |
---|---|---|
committer | Michael Kozono <mkozono@gmail.com> | 2018-03-13 16:13:37 -0700 |
commit | 3b91e56331f9070ee3edac140e642cddf4f0f15c (patch) | |
tree | 97422baeab8e27d18e8d99e9645961013da20ab4 /app | |
parent | ef62a7c2d17bb84c986d6e8db5f2bd6559803129 (diff) | |
download | gitlab-ce-3b91e56331f9070ee3edac140e642cddf4f0f15c.tar.gz |
Appease Metrics/AbcSize cop
Diffstat (limited to 'app')
-rw-r--r-- | app/models/concerns/storage/legacy_namespace.rb | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/app/models/concerns/storage/legacy_namespace.rb b/app/models/concerns/storage/legacy_namespace.rb index 4fba1494814..f05e606995d 100644 --- a/app/models/concerns/storage/legacy_namespace.rb +++ b/app/models/concerns/storage/legacy_namespace.rb @@ -13,26 +13,10 @@ module Storage expires_full_path_cache - # Move the namespace directory in all storage paths used by member projects - repository_storage_paths.each do |repository_storage_path| - # Ensure old directory exists before moving it - gitlab_shell.add_namespace(repository_storage_path, full_path_was) - - # Ensure new directory exists before moving it (if there's a parent) - gitlab_shell.add_namespace(repository_storage_path, parent.full_path) if parent - - unless gitlab_shell.mv_namespace(repository_storage_path, full_path_was, full_path) - - Rails.logger.error "Exception moving path #{repository_storage_path} from #{full_path_was} to #{full_path}" - - # if we cannot move namespace directory we should rollback - # db changes in order to prevent out of sync between db and fs - raise Gitlab::UpdatePathError.new('namespace directory cannot be moved') - end - end + move_repositories if parent_changed? - former_parent_full_path = parent_was.full_path + former_parent_full_path = parent_was&.full_path parent_full_path = parent&.full_path Gitlab::UploadsTransfer.new.move_namespace(path, former_parent_full_path, parent_full_path) Gitlab::PagesTransfer.new.move_namespace(path, former_parent_full_path, parent_full_path) @@ -68,6 +52,26 @@ module Storage private + def move_repositories + # Move the namespace directory in all storage paths used by member projects + repository_storage_paths.each do |repository_storage_path| + # Ensure old directory exists before moving it + gitlab_shell.add_namespace(repository_storage_path, full_path_was) + + # Ensure new directory exists before moving it (if there's a parent) + gitlab_shell.add_namespace(repository_storage_path, parent.full_path) if parent + + unless gitlab_shell.mv_namespace(repository_storage_path, full_path_was, full_path) + + Rails.logger.error "Exception moving path #{repository_storage_path} from #{full_path_was} to #{full_path}" + + # if we cannot move namespace directory we should rollback + # db changes in order to prevent out of sync between db and fs + raise Gitlab::UpdatePathError.new('namespace directory cannot be moved') + end + end + end + def old_repository_storage_paths @old_repository_storage_paths ||= repository_storage_paths end |