diff options
Diffstat (limited to 'app/services/bulk_imports')
4 files changed, 12 insertions, 3 deletions
diff --git a/app/services/bulk_imports/create_service.rb b/app/services/bulk_imports/create_service.rb index c1becbb5609..cbf2b34b33c 100644 --- a/app/services/bulk_imports/create_service.rb +++ b/app/services/bulk_imports/create_service.rb @@ -59,7 +59,7 @@ module BulkImports ) bulk_import.create_configuration!(credentials.slice(:url, :access_token)) - params.each do |entity| + Array.wrap(params).each do |entity| BulkImports::Entity.create!( bulk_import: bulk_import, source_type: entity[:source_type], diff --git a/app/services/bulk_imports/relation_export_service.rb b/app/services/bulk_imports/relation_export_service.rb index 4718b3914b2..14f073120c5 100644 --- a/app/services/bulk_imports/relation_export_service.rb +++ b/app/services/bulk_imports/relation_export_service.rb @@ -59,7 +59,7 @@ module BulkImports end def export_service - @export_service ||= if config.tree_relation?(relation) + @export_service ||= if config.tree_relation?(relation) || config.self_relation?(relation) TreeExportService.new(portable, config.export_path, relation) elsif config.file_relation?(relation) FileExportService.new(portable, config.export_path, relation) diff --git a/app/services/bulk_imports/tree_export_service.rb b/app/services/bulk_imports/tree_export_service.rb index b8e7ac4574b..8e885e590d1 100644 --- a/app/services/bulk_imports/tree_export_service.rb +++ b/app/services/bulk_imports/tree_export_service.rb @@ -10,6 +10,8 @@ module BulkImports end def execute + return serializer.serialize_root(config.class::SELF_RELATION) if self_relation? + relation_definition = config.tree_relation_definition_for(relation) raise BulkImports::Error, 'Unsupported relation export type' unless relation_definition @@ -18,6 +20,8 @@ module BulkImports end def exported_filename + return "#{relation}.json" if self_relation? + "#{relation}.ndjson" end @@ -39,5 +43,9 @@ module BulkImports def json_writer ::Gitlab::ImportExport::Json::NdjsonWriter.new(export_path) end + + def self_relation? + relation == config.class::SELF_RELATION + end end end diff --git a/app/services/bulk_imports/uploads_export_service.rb b/app/services/bulk_imports/uploads_export_service.rb index 32cc48c152c..7f5ee7b8624 100644 --- a/app/services/bulk_imports/uploads_export_service.rb +++ b/app/services/bulk_imports/uploads_export_service.rb @@ -5,6 +5,7 @@ module BulkImports include Gitlab::ImportExport::CommandLineUtil BATCH_SIZE = 100 + AVATAR_PATH = 'avatar' def initialize(portable, export_path) @portable = portable @@ -34,7 +35,7 @@ module BulkImports def export_subdir_path(upload) subdir = if upload.path == avatar_path - 'avatar' + AVATAR_PATH else upload.try(:secret).to_s end |