Class: BulkImports::LfsObjectsExportService
- Inherits:
-
Object
- Object
- BulkImports::LfsObjectsExportService
- Includes:
- Gitlab::ImportExport::CommandLineUtil
- Defined in:
- app/services/bulk_imports/lfs_objects_export_service.rb
Constant Summary collapse
- BATCH_SIZE =
100
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 Attribute Summary collapse
-
#exported_objects_count ⇒ Object
readonly
Returns the value of attribute exported_objects_count.
Instance Method Summary collapse
- #execute(options = {}) ⇒ Object
-
#initialize(portable, export_path) ⇒ LfsObjectsExportService
constructor
A new instance of LfsObjectsExportService.
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) ⇒ LfsObjectsExportService
Returns a new instance of LfsObjectsExportService.
11 12 13 14 15 16 |
# File 'app/services/bulk_imports/lfs_objects_export_service.rb', line 11 def initialize(portable, export_path) @portable = portable @export_path = export_path @lfs_json = {} @exported_objects_count = 0 end |
Instance Attribute Details
#exported_objects_count ⇒ Object (readonly)
Returns the value of attribute exported_objects_count.
9 10 11 |
# File 'app/services/bulk_imports/lfs_objects_export_service.rb', line 9 def exported_objects_count @exported_objects_count end |
Instance Method Details
#execute(options = {}) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/services/bulk_imports/lfs_objects_export_service.rb', line 18 def execute( = {}) relation = portable.lfs_objects if [:batch_ids] relation = relation.where(relation.model.primary_key => [:batch_ids]) # rubocop:disable CodeReuse/ActiveRecord end relation.find_in_batches(batch_size: BATCH_SIZE) do |batch| # rubocop: disable CodeReuse/ActiveRecord batch.each do |lfs_object| save_lfs_object(lfs_object) @exported_objects_count += 1 end append_lfs_json_for_batch(batch) end write_lfs_json end |