Class: Packages::Debian::ExtractMetadataService

Inherits:
Object
  • Object
show all
Includes:
Gitlab::Utils::StrongMemoize
Defined in:
app/services/packages/debian/extract_metadata_service.rb

Constant Summary collapse

ExtractionError =
Class.new(StandardError)
MAX_METADATA_FILE_SIZE =

10MB limit: accommodates largest metadata files gitlab.com/gitlab-org/gitlab/-/issues/385913#note_2546795745

10.megabytes.freeze

Instance Method Summary collapse

Constructor Details

#initialize(package_file) ⇒ ExtractMetadataService

Returns a new instance of ExtractMetadataService.



14
15
16
# File 'app/services/packages/debian/extract_metadata_service.rb', line 14

def initialize(package_file)
  @package_file = package_file
end

Instance Method Details

#executeObject

Raises:



18
19
20
21
22
23
24
25
26
27
# File 'app/services/packages/debian/extract_metadata_service.rb', line 18

def execute
  raise ExtractionError, 'invalid package file' unless valid_package_file?
  raise ExtractionError, 'invalid package file' if file_type_meta? && 

  if file_type == :unsupported
    raise ExtractionError, "unsupported file extension for file #{package_file.file_name}"
  end

  
end