Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/services/bulk_imports/file_export_service.rb')
-rw-r--r--app/services/bulk_imports/file_export_service.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/app/services/bulk_imports/file_export_service.rb b/app/services/bulk_imports/file_export_service.rb
new file mode 100644
index 00000000000..a7e0f998666
--- /dev/null
+++ b/app/services/bulk_imports/file_export_service.rb
@@ -0,0 +1,42 @@
+# frozen_string_literal: true
+
+module BulkImports
+ class FileExportService
+ include Gitlab::ImportExport::CommandLineUtil
+
+ def initialize(portable, export_path, relation)
+ @portable = portable
+ @export_path = export_path
+ @relation = relation
+ end
+
+ def execute
+ export_service.execute
+
+ archive_exported_data
+ end
+
+ def exported_filename
+ "#{relation}.tar"
+ end
+
+ private
+
+ attr_reader :export_path, :portable, :relation
+
+ def export_service
+ case relation
+ when FileTransfer::ProjectConfig::UPLOADS_RELATION
+ UploadsExportService.new(portable, export_path)
+ else
+ raise BulkImports::Error, 'Unsupported relation export type'
+ end
+ end
+
+ def archive_exported_data
+ archive_file = File.join(export_path, exported_filename)
+
+ tar_cf(archive: archive_file, dir: export_path)
+ end
+ end
+end