Class: Homebrew::RetryableDownload Private
- Includes:
- Downloadable
- Defined in:
- retryable_download.rb
This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.
Instance Method Summary collapse
- #cached_download ⇒ Pathname private
- #checksum ⇒ Checksum? private
- #clear_cache ⇒ void private
- #download_queue_name ⇒ String private
- #download_queue_type ⇒ String private
- #download_strategy ⇒ T::Class[AbstractDownloadStrategy] private
- #downloader ⇒ AbstractDownloadStrategy private
- #fetch(verify_download_integrity: true, timeout: nil, quiet: false) ⇒ Pathname private
- #initialize(downloadable, tries:, pour: false) ⇒ void constructor private
- #mirrors ⇒ Array<String> private
- #url ⇒ nil, ... private
- #verify_download_integrity(filename) ⇒ void private
- #version ⇒ Version? private
Methods included from Downloadable
#downloaded?, #freeze, #initialize_dup
Methods included from Context
current, current=, #debug?, #quiet?, #verbose?, #with_context
Constructor Details
#initialize(downloadable, tries:, pour: false) ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
21 22 23 24 25 26 27 28 |
# File 'retryable_download.rb', line 21 def initialize(downloadable, tries:, pour: false) super() @downloadable = downloadable @try = T.let(0, Integer) @tries = tries @pour = pour end |
Instance Method Details
#cached_download ⇒ Pathname
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
37 |
# File 'retryable_download.rb', line 37 def cached_download = downloadable.cached_download |
#checksum ⇒ Checksum?
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
15 |
# File 'retryable_download.rb', line 15 def checksum = downloadable.checksum |
#clear_cache ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
40 |
# File 'retryable_download.rb', line 40 def clear_cache = downloadable.clear_cache |
#download_queue_name ⇒ String
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
31 |
# File 'retryable_download.rb', line 31 def download_queue_name = downloadable.download_queue_name |
#download_queue_type ⇒ String
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
34 |
# File 'retryable_download.rb', line 34 def download_queue_type = downloadable.download_queue_type |
#download_strategy ⇒ T::Class[AbstractDownloadStrategy]
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
46 |
# File 'retryable_download.rb', line 46 def download_strategy = downloadable.download_strategy |
#downloader ⇒ AbstractDownloadStrategy
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
49 |
# File 'retryable_download.rb', line 49 def downloader = downloadable.downloader |
#fetch(verify_download_integrity: true, timeout: nil, quiet: false) ⇒ Pathname
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'retryable_download.rb', line 58 def fetch(verify_download_integrity: true, timeout: nil, quiet: false) @try += 1 already_downloaded = downloadable.downloaded? download = if downloadable.is_a?(Resource) && (resource = T.cast(downloadable, Resource)) resource.fetch(verify_download_integrity: false, timeout:, quiet:, skip_patches: true) else downloadable.fetch(verify_download_integrity: false, timeout:, quiet:) end return download unless download.file? unless quiet puts "Downloaded to: #{download}" unless already_downloaded puts "SHA256: #{download.sha256}" end json_download = downloadable.is_a?(API::JSONDownload) downloadable.verify_download_integrity(download) if verify_download_integrity && !json_download if pour && downloadable.is_a?(Bottle) HOMEBREW_CELLAR.mkpath UnpackStrategy.detect(download, prioritize_extension: true) .extract_nestedly(to: HOMEBREW_CELLAR) elsif json_download FileUtils.touch(download, mtime: Time.now) end download rescue DownloadError, ChecksumMismatchError, Resource::BottleManifest::Error tries_remaining = @tries - @try raise if tries_remaining.zero? wait = 2 ** @try unless quiet what = Utils.pluralize("tr", tries_remaining, plural: "ies", singular: "y") ohai "Retrying download in #{wait}s... (#{tries_remaining} #{what} left)" end sleep wait downloadable.clear_cache retry end |
#mirrors ⇒ Array<String>
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
18 |
# File 'retryable_download.rb', line 18 def mirrors = downloadable.mirrors |
#url ⇒ nil, ...
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
12 |
# File 'retryable_download.rb', line 12 def url = downloadable.url |
#verify_download_integrity(filename) ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
104 |
# File 'retryable_download.rb', line 104 def verify_download_integrity(filename) = downloadable.verify_download_integrity(filename) |
#version ⇒ Version?
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
43 |
# File 'retryable_download.rb', line 43 def version = downloadable.version |