module PulpFileSyncOptimizeCompatibility

Older pulp_file sync endpoints reject optimize, including explicit false. Keep the requested behavior on newer Pulp and retry only this validation error. Remove when all supported targets have pulp_file >= 3.115.0.

Public Instance Methods

sync_with_http_info(href, data, opts = {}) click to toggle source
Calls superclass method
# File lib/monkeys/pulp_file_sync_optimize.rb, line 8
def sync_with_http_info(href, data, opts = {})
  super
rescue PulpFileClient::ApiError => e
  raise unless unsupported_optimize?(e) && !opts[:debug_body]

  params = data.to_hash
  raise unless params.key?(:optimize) || params.key?('optimize')

  # Pass a hash so the generated model cannot reintroduce its optimize default.
  super(href, params.reject { |key, _| key.to_s == 'optimize' }, opts)
end

Private Instance Methods

unsupported_optimize?(error) click to toggle source
# File lib/monkeys/pulp_file_sync_optimize.rb, line 22
def unsupported_optimize?(error)
  error.code == 400 && JSON.parse(error.response_body.to_s) == {'optimize' => ['Unexpected field']}
rescue JSON::ParserError
  false
end