diff options
Diffstat (limited to 'app/services/groups')
-rw-r--r-- | app/services/groups/import_export/export_service.rb | 14 | ||||
-rw-r--r-- | app/services/groups/import_export/import_service.rb | 34 |
2 files changed, 15 insertions, 33 deletions
diff --git a/app/services/groups/import_export/export_service.rb b/app/services/groups/import_export/export_service.rb index bd54b48c5f4..2d88283661c 100644 --- a/app/services/groups/import_export/export_service.rb +++ b/app/services/groups/import_export/export_service.rb @@ -71,7 +71,7 @@ module Groups end def tree_exporter - tree_exporter_class.new( + Gitlab::ImportExport::Group::TreeSaver.new( group: group, current_user: current_user, shared: shared, @@ -79,18 +79,6 @@ module Groups ) end - def tree_exporter_class - if ndjson? - Gitlab::ImportExport::Group::TreeSaver - else - Gitlab::ImportExport::Group::LegacyTreeSaver - end - end - - def ndjson? - ::Feature.enabled?(:group_export_ndjson, group&.parent) - end - def version_saver Gitlab::ImportExport::VersionSaver.new(shared: shared) end diff --git a/app/services/groups/import_export/import_service.rb b/app/services/groups/import_export/import_service.rb index ac181245986..15948ab82a2 100644 --- a/app/services/groups/import_export/import_service.rb +++ b/app/services/groups/import_export/import_service.rb @@ -29,7 +29,7 @@ module Groups def execute Gitlab::Tracking.event(self.class.name, 'create', label: 'import_group_from_file') - if valid_user_permissions? && import_file && restorers.all?(&:restore) + if valid_user_permissions? && import_file && valid_import_file? && restorers.all?(&:restore) notify_success Gitlab::Tracking.event( @@ -75,25 +75,11 @@ module Groups def tree_restorer @tree_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) && - File.exist?(File.join(shared.export_path, 'tree/groups/_all.ndjson')) + Gitlab::ImportExport::Group::TreeRestorer.new( + user: current_user, + shared: shared, + group: group + ) end def remove_import_file @@ -115,6 +101,14 @@ module Groups end end + def valid_import_file? + return true if File.exist?(File.join(shared.export_path, 'tree/groups/_all.ndjson')) + + shared.error(::Gitlab::ImportExport::Error.incompatible_import_file_error) + + false + end + def notify_success @logger.info( group_id: group.id, |