Class: Packages::Nuget::UpdatePackageFromMetadataService
- Inherits:
-
Object
- Object
- Packages::Nuget::UpdatePackageFromMetadataService
- Includes:
- ExclusiveLeaseGuard, Gitlab::Utils::StrongMemoize
- Defined in:
- app/services/packages/nuget/update_package_from_metadata_service.rb
Constant Summary collapse
- DEFAULT_LEASE_TIMEOUT =
used by ExclusiveLeaseGuard
1.hour.to_i.freeze
- SYMBOL_PACKAGE_IDENTIFIER =
'SymbolsPackage'
- INVALID_METADATA_ERROR_MESSAGE =
'package name, version, authors and/or description not found in metadata'
- INVALID_METADATA_ERROR_SYMBOL_MESSAGE =
'package name, version and/or description not found in metadata'
- MISSING_MATCHING_PACKAGE_ERROR_MESSAGE =
'symbol package is invalid, matching package does not exist'
- InvalidMetadataError =
Class.new(StandardError)
- ZipError =
Class.new(StandardError)
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(package_file) ⇒ UpdatePackageFromMetadataService
constructor
A new instance of UpdatePackageFromMetadataService.
Methods included from ExclusiveLeaseGuard
#exclusive_lease, #lease_release?, #lease_taken_log_level, #lease_taken_message, #log_lease_taken, #release_lease, #renew_lease!, #try_obtain_lease
Constructor Details
#initialize(package_file) ⇒ UpdatePackageFromMetadataService
Returns a new instance of UpdatePackageFromMetadataService.
19 20 21 |
# File 'app/services/packages/nuget/update_package_from_metadata_service.rb', line 19 def initialize(package_file) @package_file = package_file end |
Instance Method Details
#execute ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/services/packages/nuget/update_package_from_metadata_service.rb', line 23 def execute unless = symbol_package? ? INVALID_METADATA_ERROR_SYMBOL_MESSAGE : INVALID_METADATA_ERROR_MESSAGE raise InvalidMetadataError, end try_obtain_lease do @package_file.transaction do process_package_update end end rescue ActiveRecord::RecordInvalid => e raise InvalidMetadataError, e. rescue Zip::Error raise ZipError, 'Could not open the .nupkg file' end |