From 125be1865b224c0a34ab8a1bbd62ac33b10e1d9b Mon Sep 17 00:00:00 2001 From: Ahmad Hassan Date: Thu, 17 May 2018 15:39:59 +0300 Subject: Move restore_custom_hooks to its seperate function --- lib/backup/repository.rb | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) (limited to 'lib/backup') diff --git a/lib/backup/repository.rb b/lib/backup/repository.rb index 2209a305d91..3e7590e55e3 100644 --- a/lib/backup/repository.rb +++ b/lib/backup/repository.rb @@ -67,7 +67,7 @@ module Backup end def prepare_directories - return if GitalyClient.feature_enabled?(:backup_skip_prepare_directories) + return if Gitlab::GitalyClient.feature_enabled?(:backup_skip_prepare_directories) Gitlab.config.repositories.storages.each do |name, repository_storage| gitaly_migrate(:remove_repositories) do |is_enabled| @@ -95,6 +95,24 @@ module Backup end end + def restore_custom_hooks + gitaly_migrate(:restore_custom_hooks) do |is_enabled| + # TODO: Need to find a way to do this for gitaly + # Gitaly migration issue: https://gitlab.com/gitlab-org/gitaly/issues/1195 + unless is_enabled + in_path(path_to_tars(project)) do |dir| + path_to_project_repo = path_to_repo(project) + 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 + end + end + end + def restore prepare_directories gitlab_shell = Gitlab::Shell.new @@ -123,21 +141,7 @@ module Backup progress.puts "[Failed] restoring #{project.full_path} repository".color(:red) end - gitaly_migrate(:restore_custom_hooks) do |is_enabled| - # TODO: Need to find a way to do this for gitaly - # Gitaly migration issue: https://gitlab.com/gitlab-org/gitaly/issues/1195 - unless is_enabled - in_path(path_to_tars(project)) do |dir| - path_to_project_repo = path_to_repo(project) - 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 - end - end + restore_custom_hooks unless Gitlab::GitalyClient.feature_enabled?(:backup_skip_restore_custom_hooks) wiki = ProjectWiki.new(project) path_to_wiki_bundle = path_to_bundle(wiki) -- cgit v1.2.1