Class: BulkImports::FileExportService

Inherits:
Object
  • Object
show all
Includes:
Gitlab::ImportExport::CommandLineUtil
Defined in:
app/services/bulk_imports/file_export_service.rb

Constant Summary collapse

SINGLE_OBJECT_RELATIONS =
[
  FileTransfer::ProjectConfig::REPOSITORY_BUNDLE_RELATION,
  FileTransfer::ProjectConfig::DESIGN_BUNDLE_RELATION
].freeze

Constants included from Gitlab::ImportExport::CommandLineUtil

Gitlab::ImportExport::CommandLineUtil::CLEAN_DIR_IGNORE_FILE_NAMES, Gitlab::ImportExport::CommandLineUtil::CommandLineUtilError, Gitlab::ImportExport::CommandLineUtil::DEFAULT_DIR_MODE, Gitlab::ImportExport::CommandLineUtil::FileOversizedError, Gitlab::ImportExport::CommandLineUtil::HardLinkError, Gitlab::ImportExport::CommandLineUtil::UNTAR_MASK

Instance Method Summary collapse

Methods included from Gitlab::ImportExport::CommandLineUtil

#gunzip, #gzip, #gzip_with_options, #mkdir_p, #tar_cf, #tar_czf, #untar_xf, #untar_zxf

Constructor Details

#initialize(portable, export_path, relation, user) ⇒ FileExportService

Returns a new instance of FileExportService.



12
13
14
15
16
17
# File 'app/services/bulk_imports/file_export_service.rb', line 12

def initialize(portable, export_path, relation, user)
  @portable = portable
  @export_path = export_path
  @relation = relation
  @user = user # not used anywhere in this class at the moment
end

Instance Method Details

#execute(options = {}) ⇒ Object



19
20
21
22
23
# File 'app/services/bulk_imports/file_export_service.rb', line 19

def execute(options = {})
  export_service.execute(options)

  archive_exported_data
end

#export_batch(ids) ⇒ Object



25
26
27
# File 'app/services/bulk_imports/file_export_service.rb', line 25

def export_batch(ids)
  execute(batch_ids: ids)
end

#exported_filenameObject



29
30
31
# File 'app/services/bulk_imports/file_export_service.rb', line 29

def exported_filename
  "#{relation}.tar"
end

#exported_objects_countObject



33
34
35
36
37
38
39
40
# File 'app/services/bulk_imports/file_export_service.rb', line 33

def exported_objects_count
  case relation
  when *SINGLE_OBJECT_RELATIONS
    1
  else
    export_service.exported_objects_count
  end
end