summaryrefslogtreecommitdiff
path: root/lib/backup
diff options
context:
space:
mode:
authorAhmad Hassan <ahmad.hassan612@gmail.com>2018-06-04 15:15:54 +0200
committerAhmad Hassan <ahmad.hassan612@gmail.com>2018-06-07 14:26:20 +0200
commit59a8c79f0598d4afafbebeb7e3786a03e555f85d (patch)
tree4287de9681a99264071a39e6b7b4c131ffbb9773 /lib/backup
parent717a46dd0a865d33b00cc94ec7252e706c8cd4eb (diff)
downloadgitlab-ce-59a8c79f0598d4afafbebeb7e3786a03e555f85d.tar.gz
Use RestoreCustomHooks RPC in restore rake task
Diffstat (limited to 'lib/backup')
-rw-r--r--lib/backup/repository.rb33
1 files changed, 23 insertions, 10 deletions
diff --git a/lib/backup/repository.rb b/lib/backup/repository.rb
index 1b1c83d9fb3..0119c5d6851 100644
--- a/lib/backup/repository.rb
+++ b/lib/backup/repository.rb
@@ -112,18 +112,31 @@ module Backup
end
end
+ def local_restore_custom_hooks(project, dir)
+ path_to_project_repo = Gitlab::GitalyClient::StorageSettings.allow_disk_access do
+ path_to_repo(project)
+ end
+ cmd = %W(tar -xf #{path_to_tars(project, dir)} -C #{path_to_project_repo} #{dir})
+ output, status = Gitlab::Popen.popen(cmd)
+ unless status.zero?
+ progress_warn(project, cmd.join(' '), output)
+ end
+ end
+
+ def gitaly_restore_custom_hooks(project, dir)
+ custom_hooks_path = path_to_tars(project, dir)
+ Gitlab::GitalyClient::RepositoryService.new(project.repository)
+ .restore_custom_hooks(custom_hooks_path)
+ end
+
def restore_custom_hooks(project)
- # TODO: Need to find a way to do this for gitaly
- # Gitaly migration issue: https://gitlab.com/gitlab-org/gitaly/issues/1195
in_path(path_to_tars(project)) do |dir|
- path_to_project_repo = Gitlab::GitalyClient::StorageSettings.allow_disk_access do
- path_to_repo(project)
- end
- cmd = %W(tar -xf #{path_to_tars(project, dir)} -C #{path_to_project_repo} #{dir})
-
- output, status = Gitlab::Popen.popen(cmd)
- unless status.zero?
- progress_warn(project, cmd.join(' '), output)
+ gitaly_migrate(:restore_custom_hooks) do |is_enabled|
+ if is_enabled
+ local_restore_custom_hooks(project, dir)
+ else
+ gitaly_restore_custom_hooks(project, dir)
+ end
end
end
end