Class: AbstractFileDownloadStrategy

Inherits:
AbstractDownloadStrategy show all
Defined in:
brew/Library/Homebrew/download_strategy.rb

Instance Attribute Summary

Attributes inherited from AbstractDownloadStrategy

#cache, #source_modified_time, #url

Instance Method Summary collapse

Methods inherited from AbstractDownloadStrategy

#clear_cache, #fetch, #initialize, #ohai, #puts, #shutup!, #stage

Constructor Details

This class inherits a constructor from AbstractDownloadStrategy

Instance Method Details

#basenameObject



222
223
224
# File 'brew/Library/Homebrew/download_strategy.rb', line 222

def basename
  cached_location.basename.sub(/^[\da-f]{64}\-\-/, "")
end

#cached_locationObject



208
209
210
211
212
213
214
215
216
217
218
219
220
# File 'brew/Library/Homebrew/download_strategy.rb', line 208

def cached_location
  return @cached_location if defined?(@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 = if downloads.count == 1
    downloads.first
  else
    HOMEBREW_CACHE/"downloads/#{url_sha256}--#{resolved_basename}"
  end
end


201
202
203
204
205
206
# File 'brew/Library/Homebrew/download_strategy.rb', line 201

def symlink_location
  return @symlink_location if defined?(@symlink_location)

  ext = Pathname(parse_basename(url)).extname
  @symlink_location = @cache/"#{name}--#{version}#{ext}"
end

#temporary_pathObject



197
198
199
# File 'brew/Library/Homebrew/download_strategy.rb', line 197

def temporary_path
  @temporary_path ||= Pathname.new("#{cached_location}.incomplete")
end