Class: AbstractFileDownloadStrategy Abstract Private
- Inherits:
-
AbstractDownloadStrategy
- Object
- AbstractDownloadStrategy
- AbstractFileDownloadStrategy
- Defined in:
- download_strategy.rb
Overview
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.
Abstract superclass for all download strategies downloading a single file.
Direct Known Subclasses
CurlDownloadStrategy, GitHubArtifactDownloadStrategy, LocalBottleDownloadStrategy
Instance Attribute Summary
Attributes inherited from AbstractDownloadStrategy
Instance Method Summary collapse
- #basename ⇒ Pathname private
-
#cached_location ⇒ Pathname
Path for storing the completed download.
-
#symlink_location ⇒ Pathname
Path of the symlink (whose name includes the resource name, version and extension) pointing to #cached_location.
-
#temporary_path ⇒ Pathname
Path for storing an incomplete download while the download is still in progress.
Methods inherited from AbstractDownloadStrategy
#clear_cache, #fetch, #initialize, #quiet!, #quiet?, #source_modified_time, #stage
Methods included from SystemCommand::Mixin
#system_command, #system_command!
Methods included from Context
current, current=, #debug?, #quiet?, #verbose?, #with_context
Constructor Details
This class inherits a constructor from AbstractDownloadStrategy
Instance Method Details
#basename ⇒ 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.
355 356 357 |
# File 'download_strategy.rb', line 355 def basename cached_location.basename.sub(/^[\da-f]{64}--/, "") end |
#cached_location ⇒ Pathname
Path for storing the completed download.
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 |
# File 'download_strategy.rb', line 337 def cached_location return @cached_location if @cached_location url_sha256 = Digest::SHA256.hexdigest(url) downloads = Pathname.glob(HOMEBREW_CACHE/"downloads/#{url_sha256}--*") .reject { |path| path.extname.end_with?(".incomplete") } @cached_location = T.let( if downloads.count == 1 downloads.fetch(0) else HOMEBREW_CACHE/"downloads/#{url_sha256}--#{Utils.safe_filename(resolved_basename)}" end, T.nilable(Pathname) ) T.must(@cached_location) end |
#symlink_location ⇒ Pathname
Path of the symlink (whose name includes the resource name, version and extension) pointing to #cached_location.
325 326 327 328 329 330 331 |
# File 'download_strategy.rb', line 325 def symlink_location return T.must(@symlink_location) if defined?(@symlink_location) ext = Pathname(parse_basename(url)).extname @symlink_location = T.let(@cache/Utils.safe_filename("#{name}--#{version}#{ext}"), T.nilable(Pathname)) T.must(@symlink_location) end |