diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
commit | 7e9c479f7de77702622631cff2628a9c8dcbc627 (patch) | |
tree | c8f718a08e110ad7e1894510980d2155a6549197 /app/models/project_repository_storage_move.rb | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'app/models/project_repository_storage_move.rb')
-rw-r--r-- | app/models/project_repository_storage_move.rb | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/app/models/project_repository_storage_move.rb b/app/models/project_repository_storage_move.rb index 76f428fe925..3429dbe3a85 100644 --- a/app/models/project_repository_storage_move.rb +++ b/app/models/project_repository_storage_move.rb @@ -46,8 +46,15 @@ class ProjectRepositoryStorageMove < ApplicationRecord transition replicated: :cleanup_failed end - after_transition initial: :scheduled do |storage_move| - storage_move.project.update_column(:repository_read_only, true) + around_transition initial: :scheduled do |storage_move, block| + block.call + + begin + storage_move.project.set_repository_read_only! + rescue => err + errors.add(:project, err.message) + next false + end storage_move.run_after_commit do ProjectUpdateRepositoryStorageWorker.perform_async( @@ -56,17 +63,18 @@ class ProjectRepositoryStorageMove < ApplicationRecord storage_move.id ) end + + true end - after_transition started: :replicated do |storage_move| - storage_move.project.update_columns( - repository_read_only: false, - repository_storage: storage_move.destination_storage_name - ) + before_transition started: :replicated do |storage_move| + storage_move.project.set_repository_writable! + + storage_move.project.update_column(:repository_storage, storage_move.destination_storage_name) end - after_transition started: :failed do |storage_move| - storage_move.project.update_column(:repository_read_only, false) + before_transition started: :failed do |storage_move| + storage_move.project.set_repository_writable! end state :initial, value: 1 |