Class: BulkImports::Common::Pipelines::LfsObjectsPipeline
- Inherits:
-
Object
- Object
- BulkImports::Common::Pipelines::LfsObjectsPipeline
- Includes:
- Pipeline
- Defined in:
- lib/bulk_imports/common/pipelines/lfs_objects_pipeline.rb
Constant Summary
Constants included from Pipeline
Pipeline::CACHE_KEY_EXPIRATION, Pipeline::EMPTY_EXPORT_STATUS_TIMEOUT, Pipeline::ExpiredError, Pipeline::FailedError, Pipeline::NDJSON_EXPORT_TIMEOUT, Pipeline::NotAllowedError
Constants included from Pipeline::Runner
Pipeline::Runner::MarkedAsFailedError
Instance Method Summary collapse
-
#after_run(_) ⇒ Object
rubocop: enable CodeReuse/ActiveRecord.
- #extract(_context) ⇒ Object
-
#load(_context, file_path) ⇒ Object
rubocop: disable CodeReuse/ActiveRecord.
Methods included from Pipeline
#current_user, #import_export_config, #initialize, #portable, #tracker
Methods included from Pipeline::Runner
Instance Method Details
#after_run(_) ⇒ Object
rubocop: enable CodeReuse/ActiveRecord
44 45 46 |
# File 'lib/bulk_imports/common/pipelines/lfs_objects_pipeline.rb', line 44 def after_run(_) FileUtils.remove_entry(tmpdir) if Dir.exist?(tmpdir) end |
#extract(_context) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/bulk_imports/common/pipelines/lfs_objects_pipeline.rb', line 11 def extract(_context) download_service.execute decompression_service.execute extraction_service.execute file_paths = Dir.glob(File.join(tmpdir, '*')) BulkImports::Pipeline::ExtractedData.new(data: file_paths) end |
#load(_context, file_path) ⇒ Object
rubocop: disable CodeReuse/ActiveRecord
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/bulk_imports/common/pipelines/lfs_objects_pipeline.rb', line 22 def load(_context, file_path) Gitlab::PathTraversal.check_path_traversal!(file_path) Gitlab::PathTraversal.check_allowed_absolute_path!(file_path, [Dir.tmpdir]) return if tar_filepath?(file_path) return if lfs_json_filepath?(file_path) return if File.directory?(file_path) return if Gitlab::Utils::FileInfo.linked?(file_path) size = File.size(file_path) oid = LfsObject.calculate_oid(file_path) lfs_object = LfsObject.find_or_initialize_by(oid: oid, size: size) lfs_object.file = File.open(file_path) unless lfs_object.file&.exists? lfs_object.save! if lfs_object.changed? repository_types(oid)&.each do |type| create_lfs_objects_project(lfs_object, type) end end |