diff options
Diffstat (limited to 'app/services/groups/import_export')
-rw-r--r-- | app/services/groups/import_export/export_service.rb | 24 | ||||
-rw-r--r-- | app/services/groups/import_export/import_service.rb | 34 |
2 files changed, 47 insertions, 11 deletions
diff --git a/app/services/groups/import_export/export_service.rb b/app/services/groups/import_export/export_service.rb index f8715b57d6e..0f2e3bb65f9 100644 --- a/app/services/groups/import_export/export_service.rb +++ b/app/services/groups/import_export/export_service.rb @@ -52,11 +52,11 @@ module Groups end def savers - [tree_exporter, file_saver] + [version_saver, tree_exporter, file_saver] end def tree_exporter - Gitlab::ImportExport::Group::LegacyTreeSaver.new( + tree_exporter_class.new( group: @group, current_user: @current_user, shared: @shared, @@ -64,6 +64,18 @@ module Groups ) end + def tree_exporter_class + if ::Feature.enabled?(:group_export_ndjson, @group&.parent, default_enabled: true) + Gitlab::ImportExport::Group::TreeSaver + else + Gitlab::ImportExport::Group::LegacyTreeSaver + end + end + + def version_saver + Gitlab::ImportExport::VersionSaver.new(shared: shared) + end + def file_saver Gitlab::ImportExport::Saver.new(exportable: @group, shared: @shared) end @@ -84,6 +96,8 @@ module Groups group_name: @group.name, message: 'Group Import/Export: Export succeeded' ) + + notification_service.group_was_exported(@group, @current_user) end def notify_error @@ -93,6 +107,12 @@ module Groups error: @shared.errors.join(', '), message: 'Group Import/Export: Export failed' ) + + notification_service.group_was_not_exported(@group, @current_user, @shared.errors) + end + + def notification_service + @notification_service ||= NotificationService.new end end end diff --git a/app/services/groups/import_export/import_service.rb b/app/services/groups/import_export/import_service.rb index f62b9d3c8a6..6f692c98c38 100644 --- a/app/services/groups/import_export/import_service.rb +++ b/app/services/groups/import_export/import_service.rb @@ -27,18 +27,34 @@ module Groups private def import_file - @import_file ||= Gitlab::ImportExport::FileImporter.import(importable: @group, - archive_file: nil, - shared: @shared) + @import_file ||= Gitlab::ImportExport::FileImporter.import( + importable: @group, + archive_file: nil, + shared: @shared + ) end def restorer - @restorer ||= Gitlab::ImportExport::Group::LegacyTreeRestorer.new( - user: @current_user, - shared: @shared, - group: @group, - group_hash: nil - ) + @restorer ||= + if ndjson? + Gitlab::ImportExport::Group::TreeRestorer.new( + user: @current_user, + shared: @shared, + group: @group + ) + else + Gitlab::ImportExport::Group::LegacyTreeRestorer.new( + user: @current_user, + shared: @shared, + group: @group, + group_hash: nil + ) + end + end + + def ndjson? + ::Feature.enabled?(:group_import_ndjson, @group&.parent, default_enabled: true) && + File.exist?(File.join(@shared.export_path, 'tree/groups/_all.ndjson')) end def remove_import_file |