Remove the need for ensure_cache_exists.

This commit is contained in:
Markus Reiter 2018-06-09 10:41:14 +02:00
parent 9ebcef785e
commit b2f67c6d77
6 changed files with 6 additions and 18 deletions

View File

@ -28,7 +28,6 @@ require "hbc/version"
module Hbc
def self.init
Cache.ensure_cache_exists
Caskroom.ensure_caskroom_exists
end
end

View File

@ -5,12 +5,5 @@ module Hbc
def path
@path ||= HOMEBREW_CACHE.join("Cask")
end
def ensure_cache_exists
return if path.exist?
odebug "Creating Cache at #{path}"
path.mkpath
end
end
end

View File

@ -8,10 +8,6 @@ module Hbc
"cleans up cached downloads and tracker symlinks"
end
def self.needs_init?
true
end
attr_reader :cache_location
def initialize(*args, cache_location: Cache.path)
@ -24,7 +20,7 @@ module Hbc
end
def cache_files
return [] unless cache_location.exist?
return [] unless cache_location.directory?
cache_location.children
.map(&method(:Pathname))
.reject(&method(:outdated?))

View File

@ -17,10 +17,6 @@ module Hbc
end
end
def self.needs_init?
true
end
def self.help
"downloads remote application files to local cache"
end

View File

@ -95,6 +95,8 @@ module Hbc
end
def fetch
tarball_path.dirname.mkpath
ohai "Downloading #{@url}"
if tarball_path.exist?
puts "Already downloaded: #{tarball_path}"
@ -193,6 +195,8 @@ module Hbc
# super does not provide checks for already-existing downloads
def fetch
cached_location.dirname.mkpath
if cached_location.directory?
puts "Already downloaded: #{cached_location}"
else

View File

@ -23,7 +23,7 @@ RSpec.shared_context "Homebrew-Cask" do
begin
HOMEBREW_CASK_DIRS.values.each(&:mkpath)
[Hbc::Config.global.binarydir, Hbc::Caskroom.path, Hbc::Cache.path].each(&:mkpath)
[Hbc::Config.global.binarydir, Hbc::Caskroom.path].each(&:mkpath)
Tap.default_cask_tap.tap do |tap|
FileUtils.mkdir_p tap.path.dirname