more refactoring - easier guessing path changes
This commit is contained in:
parent
45032bf403
commit
8f973b8f68
|
@ -2,8 +2,8 @@ module Projects
|
|||
module ImportExport
|
||||
class ExportService < BaseService
|
||||
def execute(options = {})
|
||||
|
||||
@import_path = options[:import_path]
|
||||
archive_file = options[:archive_file]
|
||||
Gitlab::ImportExport::Importer.import(archive_file: archive_file, storage_path: storage_path)
|
||||
restore_project_tree
|
||||
restore_repo(project_tree.project)
|
||||
end
|
||||
|
@ -15,11 +15,15 @@ module Projects
|
|||
end
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
|
|
@ -24,13 +24,13 @@ module Gitlab
|
|||
end
|
||||
|
||||
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)
|
||||
status.zero?
|
||||
end
|
||||
|
||||
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)
|
||||
status.zero?
|
||||
end
|
||||
|
|
|
@ -7,19 +7,19 @@ module Gitlab
|
|||
new(*args).import
|
||||
end
|
||||
|
||||
def initialize(archive_file:, storage_path:)
|
||||
def initialize(archive_file: , storage_path:)
|
||||
@archive_file = archive_file
|
||||
@storage_path = storage_path
|
||||
end
|
||||
|
||||
def import
|
||||
decompress_export
|
||||
decompress_archive
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def decompress
|
||||
untar_czf(archive: archive_file, dir: @storage_path)
|
||||
def decompress_archive
|
||||
untar_czf(archive: @archive_file, dir: @storage_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,7 +4,7 @@ module Gitlab
|
|||
attr_reader :project
|
||||
|
||||
def initialize(path:, user:)
|
||||
@path = path
|
||||
@path = File.join(path, 'project.json')
|
||||
@user = user
|
||||
end
|
||||
|
||||
|
|
|
@ -3,9 +3,9 @@ module Gitlab
|
|||
class RepoRestorer
|
||||
include Gitlab::ImportExport::CommandLineUtil
|
||||
|
||||
def initialize(project: , path: )
|
||||
def initialize(project: , path:, bundler_file: )
|
||||
@project = project
|
||||
@path = path
|
||||
@path = File.join(path, bundler_file)
|
||||
end
|
||||
|
||||
def restore
|
||||
|
|
Loading…
Reference in New Issue