more refactoring - easier guessing path changes
This commit is contained in:
parent
45032bf403
commit
8f973b8f68
|
@ -2,8 +2,8 @@ module Projects
|
||||||
module ImportExport
|
module ImportExport
|
||||||
class ExportService < BaseService
|
class ExportService < BaseService
|
||||||
def execute(options = {})
|
def execute(options = {})
|
||||||
|
archive_file = options[:archive_file]
|
||||||
@import_path = options[:import_path]
|
Gitlab::ImportExport::Importer.import(archive_file: archive_file, storage_path: storage_path)
|
||||||
restore_project_tree
|
restore_project_tree
|
||||||
restore_repo(project_tree.project)
|
restore_repo(project_tree.project)
|
||||||
end
|
end
|
||||||
|
@ -15,11 +15,15 @@ module Projects
|
||||||
end
|
end
|
||||||
|
|
||||||
def project_tree
|
def project_tree
|
||||||
@project_tree ||= Gitlab::ImportExport::ProjectTreeRestorer.new(path: @import_path, user: @current_user)
|
@project_tree ||= Gitlab::ImportExport::ProjectTreeRestorer.new(path: storage_path, user: @current_user)
|
||||||
end
|
end
|
||||||
|
|
||||||
def restore_repo(project)
|
def restore_repo(project)
|
||||||
Gitlab::ImportExport::RepoRestorer.new(path: @import_path, project: project).restore
|
Gitlab::ImportExport::RepoRestorer.new(path: storage_path, project: project).restore
|
||||||
|
end
|
||||||
|
|
||||||
|
def storage_path
|
||||||
|
@storage_path ||= Gitlab::ImportExport.export_path(relative_path: project.path_with_namespace)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,13 +24,13 @@ module Gitlab
|
||||||
end
|
end
|
||||||
|
|
||||||
def tar_with_options(archive:, dir:, options:)
|
def tar_with_options(archive:, dir:, options:)
|
||||||
cmd = %W(tar -#{options} #{archive} -C #{dir} .)
|
cmd = %W(tar -#{options} #{archive} -C #{dir})
|
||||||
_output, status = Gitlab::Popen.popen(cmd)
|
_output, status = Gitlab::Popen.popen(cmd)
|
||||||
status.zero?
|
status.zero?
|
||||||
end
|
end
|
||||||
|
|
||||||
def untar_with_options(archive:, dir:, options:)
|
def untar_with_options(archive:, dir:, options:)
|
||||||
cmd = %W(tar -#{options} #{archive)} -C #{dir})
|
cmd = %W(tar -#{options} #{archive} -C #{dir})
|
||||||
_output, status = Gitlab::Popen.popen(cmd)
|
_output, status = Gitlab::Popen.popen(cmd)
|
||||||
status.zero?
|
status.zero?
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,13 +13,13 @@ module Gitlab
|
||||||
end
|
end
|
||||||
|
|
||||||
def import
|
def import
|
||||||
decompress_export
|
decompress_archive
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def decompress
|
def decompress_archive
|
||||||
untar_czf(archive: archive_file, dir: @storage_path)
|
untar_czf(archive: @archive_file, dir: @storage_path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,7 +4,7 @@ module Gitlab
|
||||||
attr_reader :project
|
attr_reader :project
|
||||||
|
|
||||||
def initialize(path:, user:)
|
def initialize(path:, user:)
|
||||||
@path = path
|
@path = File.join(path, 'project.json')
|
||||||
@user = user
|
@user = user
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,9 @@ module Gitlab
|
||||||
class RepoRestorer
|
class RepoRestorer
|
||||||
include Gitlab::ImportExport::CommandLineUtil
|
include Gitlab::ImportExport::CommandLineUtil
|
||||||
|
|
||||||
def initialize(project: , path: )
|
def initialize(project: , path:, bundler_file: )
|
||||||
@project = project
|
@project = project
|
||||||
@path = path
|
@path = File.join(path, bundler_file)
|
||||||
end
|
end
|
||||||
|
|
||||||
def restore
|
def restore
|
||||||
|
|
Loading…
Reference in New Issue