2016-06-22 15:30:34 +05:30
|
|
|
module Gitlab
|
|
|
|
module ImportExport
|
|
|
|
class Shared
|
|
|
|
attr_reader :errors, :opts
|
|
|
|
|
|
|
|
def initialize(opts)
|
|
|
|
@opts = opts
|
|
|
|
@errors = []
|
|
|
|
end
|
|
|
|
|
|
|
|
def export_path
|
2018-03-17 18:26:18 +05:30
|
|
|
@export_path ||= Gitlab::ImportExport.export_path(relative_path: relative_path)
|
|
|
|
end
|
|
|
|
|
|
|
|
def archive_path
|
|
|
|
@archive_path ||= Gitlab::ImportExport.export_path(relative_path: relative_archive_path)
|
2016-06-22 15:30:34 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def error(error)
|
|
|
|
error_out(error.message, caller[0].dup)
|
|
|
|
@errors << error.message
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2016-06-22 15:30:34 +05:30
|
|
|
# Debug:
|
2018-03-17 18:26:18 +05:30
|
|
|
if error.backtrace
|
|
|
|
Rails.logger.error("Import/Export backtrace: #{error.backtrace.join("\n")}")
|
|
|
|
else
|
|
|
|
Rails.logger.error("No backtrace found")
|
|
|
|
end
|
2016-06-22 15:30:34 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
def relative_path
|
|
|
|
File.join(opts[:relative_path], SecureRandom.hex)
|
|
|
|
end
|
|
|
|
|
|
|
|
def relative_archive_path
|
|
|
|
File.join(opts[:relative_path], '..')
|
|
|
|
end
|
|
|
|
|
2016-06-22 15:30:34 +05:30
|
|
|
def error_out(message, caller)
|
|
|
|
Rails.logger.error("Import/Export error raised on #{caller}: #{message}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|