Commit 125be186 authored by Ahmad Hassan's avatar Ahmad Hassan

Move restore_custom_hooks to its seperate function

parent 62f29887
...@@ -67,7 +67,7 @@ module Backup ...@@ -67,7 +67,7 @@ module Backup
end end
def prepare_directories 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| Gitlab.config.repositories.storages.each do |name, repository_storage|
gitaly_migrate(:remove_repositories) do |is_enabled| gitaly_migrate(:remove_repositories) do |is_enabled|
...@@ -95,6 +95,24 @@ module Backup ...@@ -95,6 +95,24 @@ module Backup
end end
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 def restore
prepare_directories prepare_directories
gitlab_shell = Gitlab::Shell.new gitlab_shell = Gitlab::Shell.new
...@@ -123,21 +141,7 @@ module Backup ...@@ -123,21 +141,7 @@ module Backup
progress.puts "[Failed] restoring #{project.full_path} repository".color(:red) progress.puts "[Failed] restoring #{project.full_path} repository".color(:red)
end end
gitaly_migrate(:restore_custom_hooks) do |is_enabled| restore_custom_hooks unless Gitlab::GitalyClient.feature_enabled?(:backup_skip_restore_custom_hooks)
# 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
wiki = ProjectWiki.new(project) wiki = ProjectWiki.new(project)
path_to_wiki_bundle = path_to_bundle(wiki) path_to_wiki_bundle = path_to_bundle(wiki)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment