Class: GitHubArtifactDownloadStrategy

Inherits:
AbstractFileDownloadStrategy show all
Defined in:
brew/Library/Homebrew/dev-cmd/pr-pull.rb

Instance Attribute Summary

Attributes inherited from AbstractDownloadStrategy

#cache, #cached_location, #source_modified_time, #url

Instance Method Summary collapse

Methods inherited from AbstractFileDownloadStrategy

#basename, #cached_location, #symlink_location, #temporary_path

Methods inherited from AbstractDownloadStrategy

#basename, #clear_cache, #initialize, #quiet?, #shutup!, #stage

Methods included from Context

current, current=, #debug?, #quiet?, #verbose?, #with_context

Constructor Details

This class inherits a constructor from AbstractDownloadStrategy

Instance Method Details

#fetchObject



437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
# File 'brew/Library/Homebrew/dev-cmd/pr-pull.rb', line 437

def fetch
  ohai "Downloading #{url}"
  if cached_location.exist?
    puts "Already downloaded: #{cached_location}"
  else
    begin
      curl "--location", "--create-dirs", "--output", temporary_path, url,
           *meta.fetch(:curl_args, []),
           secrets: meta.fetch(:secrets, [])
    rescue ErrorDuringExecution
      raise CurlDownloadStrategyError, url
    end
    ignore_interrupts do
      cached_location.dirname.mkpath
      temporary_path.rename(cached_location)
      symlink_location.dirname.mkpath
    end
  end
  FileUtils.ln_s cached_location.relative_path_from(symlink_location.dirname), symlink_location, force: true
end