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?
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def install_time
 | 
			
		||||
      _, time = timestamped_versions.last
 | 
			
		||||
      return unless time
 | 
			
		||||
 | 
			
		||||
      Time.strptime(time, Metadata::TIMESTAMP_FORMAT)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def installed_caskfile
 | 
			
		||||
      installed_version = timestamped_versions.last
 | 
			
		||||
      metadata_master_container_path.join(*installed_version, "Casks", "#{token}.rb")
 | 
			
		||||
 | 
			
		||||
@ -35,7 +35,7 @@ module Cask
 | 
			
		||||
    attr_accessor :downloaded_path
 | 
			
		||||
 | 
			
		||||
    def clear_cache
 | 
			
		||||
      downloader.clear_cache if force || cask.version.latest?
 | 
			
		||||
      downloader.clear_cache if force
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def fetch
 | 
			
		||||
 | 
			
		||||
@ -3,6 +3,7 @@
 | 
			
		||||
module Cask
 | 
			
		||||
  module Metadata
 | 
			
		||||
    METADATA_SUBDIR = ".metadata"
 | 
			
		||||
    TIMESTAMP_FORMAT = "%Y%m%d%H%M%S.%L"
 | 
			
		||||
 | 
			
		||||
    def metadata_master_container_path
 | 
			
		||||
      @metadata_master_container_path ||= caskroom_path.join(METADATA_SUBDIR)
 | 
			
		||||
@ -58,12 +59,7 @@ module Cask
 | 
			
		||||
    private
 | 
			
		||||
 | 
			
		||||
    def new_timestamp(time = Time.now)
 | 
			
		||||
      time = time.utc
 | 
			
		||||
 | 
			
		||||
      timestamp = time.strftime("%Y%m%d%H%M%S")
 | 
			
		||||
      fraction = format("%.3f", time.to_f - time.to_i)[1..-1]
 | 
			
		||||
 | 
			
		||||
      timestamp.concat(fraction)
 | 
			
		||||
      time.utc.strftime(TIMESTAMP_FORMAT)
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
@ -296,6 +296,8 @@ class CurlDownloadStrategy < AbstractFileDownloadStrategy
 | 
			
		||||
 | 
			
		||||
      fresh = if cached_location.exist? && url_time
 | 
			
		||||
        url_time <= cached_location.mtime
 | 
			
		||||
      elsif version.respond_to?(:latest?)
 | 
			
		||||
        !version.latest?
 | 
			
		||||
      else
 | 
			
		||||
        true
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user