summaryrefslogtreecommitdiff
path: root/lib/backup
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2018-06-08 11:49:13 +0000
committerDouwe Maan <douwe@gitlab.com>2018-06-08 11:49:13 +0000
commitf068479e637c52b839c3474a87c2d01e82ba0829 (patch)
tree07cb0c54629d9374677de06f0ebf1de3766a92e5 /lib/backup
parentd0a040d315f160a1f6700cdb2aa8d194c2104f55 (diff)
parent2bbac66cae09a1dde81121399daa56bf166dd78e (diff)
downloadgitlab-ce-f068479e637c52b839c3474a87c2d01e82ba0829.tar.gz
Merge branch 'use-restore-custom-hooks-gitaly' into 'master'
Use RestoreCustomHooks RPC in restore rake task See merge request gitlab-org/gitlab-ce!19370
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