Class: BulkImports::Common::Pipelines::UploadsPipeline
- Inherits:
-
Object
- Object
- BulkImports::Common::Pipelines::UploadsPipeline
- Includes:
- Pipeline
- Defined in:
- lib/bulk_imports/common/pipelines/uploads_pipeline.rb
Constant Summary collapse
- AVATAR_PATTERN =
%r{.*\/#{BulkImports::UploadsExportService::AVATAR_PATH}\/(?<identifier>.*)}
- AvatarLoadingError =
Class.new(StandardError)
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
Methods included from Pipeline
#current_user, #import_export_config, #initialize, #portable, #tracker
Methods included from Pipeline::Runner
Instance Method Details
#after_run(_) ⇒ Object
42 43 44 |
# File 'lib/bulk_imports/common/pipelines/uploads_pipeline.rb', line 42 def after_run(_) FileUtils.remove_entry(tmpdir) if Dir.exist?(tmpdir) end |
#extract(_context) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/bulk_imports/common/pipelines/uploads_pipeline.rb', line 15 def extract(_context) download_service.execute decompression_service.execute extraction_service.execute upload_file_paths = Dir.glob(File.join(tmpdir, '**', '*')) BulkImports::Pipeline::ExtractedData.new(data: upload_file_paths) end |
#load(context, file_path) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/bulk_imports/common/pipelines/uploads_pipeline.rb', line 25 def load(context, file_path) # Validate that the path is OK to load Gitlab::PathTraversal.check_allowed_absolute_path_and_path_traversal!(file_path, [Dir.tmpdir]) return if File.directory?(file_path) return if Gitlab::Utils::FileInfo.linked?(file_path) avatar_path = AVATAR_PATTERN.match(file_path) return save_avatar(file_path) if avatar_path dynamic_path = file_uploader.extract_dynamic_path(file_path) return unless dynamic_path named_captures = dynamic_path.named_captures.symbolize_keys UploadService.new(context.portable, File.open(file_path, 'r'), file_uploader, **named_captures).execute end |