Merge pull request #6195 from reitermarkus/latest-cask-downloads
Don't redownload “latest” casks unnecessarily.
This commit is contained in:
commit
eec2928754
@ -80,6 +80,13 @@ module Cask
|
|||||||
!versions.empty?
|
!versions.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def install_time
|
||||||
|
_, time = timestamped_versions.last
|
||||||
|
return unless time
|
||||||
|
|
||||||
|
Time.strptime(time, Metadata::TIMESTAMP_FORMAT)
|
||||||
|
end
|
||||||
|
|
||||||
def installed_caskfile
|
def installed_caskfile
|
||||||
installed_version = timestamped_versions.last
|
installed_version = timestamped_versions.last
|
||||||
metadata_master_container_path.join(*installed_version, "Casks", "#{token}.rb")
|
metadata_master_container_path.join(*installed_version, "Casks", "#{token}.rb")
|
||||||
|
|||||||
@ -35,7 +35,7 @@ module Cask
|
|||||||
attr_accessor :downloaded_path
|
attr_accessor :downloaded_path
|
||||||
|
|
||||||
def clear_cache
|
def clear_cache
|
||||||
downloader.clear_cache if force || cask.version.latest?
|
downloader.clear_cache if force
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch
|
def fetch
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
module Cask
|
module Cask
|
||||||
module Metadata
|
module Metadata
|
||||||
METADATA_SUBDIR = ".metadata"
|
METADATA_SUBDIR = ".metadata"
|
||||||
|
TIMESTAMP_FORMAT = "%Y%m%d%H%M%S.%L"
|
||||||
|
|
||||||
def metadata_master_container_path
|
def metadata_master_container_path
|
||||||
@metadata_master_container_path ||= caskroom_path.join(METADATA_SUBDIR)
|
@metadata_master_container_path ||= caskroom_path.join(METADATA_SUBDIR)
|
||||||
@ -58,12 +59,7 @@ module Cask
|
|||||||
private
|
private
|
||||||
|
|
||||||
def new_timestamp(time = Time.now)
|
def new_timestamp(time = Time.now)
|
||||||
time = time.utc
|
time.utc.strftime(TIMESTAMP_FORMAT)
|
||||||
|
|
||||||
timestamp = time.strftime("%Y%m%d%H%M%S")
|
|
||||||
fraction = format("%.3f", time.to_f - time.to_i)[1..-1]
|
|
||||||
|
|
||||||
timestamp.concat(fraction)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -296,6 +296,8 @@ class CurlDownloadStrategy < AbstractFileDownloadStrategy
|
|||||||
|
|
||||||
fresh = if cached_location.exist? && url_time
|
fresh = if cached_location.exist? && url_time
|
||||||
url_time <= cached_location.mtime
|
url_time <= cached_location.mtime
|
||||||
|
elsif version.respond_to?(:latest?)
|
||||||
|
!version.latest?
|
||||||
else
|
else
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user