Skip to content

Commit

Permalink
Fix :svn download errors with :latest casks
Browse files Browse the repository at this point in the history
  • Loading branch information
apainintheneck committed Jun 1, 2022
1 parent 4054728 commit 6f06236
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions Library/Homebrew/cask/cask.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,26 @@ def config_path
metadata_main_container_path/"config.json"
end

def checksumable?
url.using.blank? || url.using == :post
end

def download_sha_path
metadata_main_container_path/"LATEST_DOWNLOAD_SHA256"
end

def new_download_sha
require "cask/installer"

# Call checksumable? before hashing
@new_download_sha ||= Installer.new(self, verify_download_integrity: false)
.download(quiet: true)
.instance_eval { |x| Digest::SHA256.file(x).hexdigest }
end

def outdated_download_sha?
return true unless checksumable?

current_download_sha = download_sha_path.read if download_sha_path.exist?
current_download_sha.blank? || current_download_sha != new_download_sha
end
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ def save_config_file
end

def save_download_sha
@cask.download_sha_path.atomic_write(@cask.new_download_sha)
@cask.download_sha_path.atomic_write(@cask.new_download_sha) if @cask.checksumable?
end

def uninstall
Expand Down

0 comments on commit 6f06236

Please sign in to comment.