diff options
Diffstat (limited to 'app/services/bulk_imports/file_export_service.rb')
-rw-r--r-- | app/services/bulk_imports/file_export_service.rb | 42 |
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 |