Skip to content

Commit e2ed81b

Browse files
committed
Improved vendor cleanup
1 parent 224bba5 commit e2ed81b

1 file changed

Lines changed: 12 additions & 14 deletions

File tree

ext/or-tools/vendor.rb

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -70,24 +70,22 @@
7070
short_version = version.split(".").first(2).join(".")
7171
url = "https://github.com/google/or-tools/releases/download/v#{short_version}/#{filename}"
7272

73-
# download
74-
download_path = "#{Dir.tmpdir}/#{filename}"
75-
unless File.exist?(download_path)
76-
puts "Downloading #{url}..."
77-
IO.copy_stream(URI.parse(url).open(max_redirects: 10), download_path)
78-
end
79-
80-
# check integrity - do this regardless of if just downloaded
81-
download_checksum = Digest::SHA256.file(download_path).hexdigest
82-
raise "Bad checksum: #{download_checksum}" if download_checksum != checksum
83-
8473
path = File.expand_path("../../tmp/or-tools", __dir__)
8574
FileUtils.mkdir_p(path)
8675

87-
# extract - can't use Gem::Package#extract_tar_gz from RubyGems
88-
# since it limits filenames to 100 characters (doesn't support UStar format)
89-
# for space, only keep licenses, include, and shared library
9076
Dir.mktmpdir do |extract_path|
77+
# download
78+
download_path = "#{extract_path}/#{filename}"
79+
puts "Downloading #{url}..."
80+
IO.copy_stream(URI.parse(url).open(max_redirects: 10), download_path)
81+
82+
# check integrity
83+
download_checksum = Digest::SHA256.file(download_path).hexdigest
84+
raise "Bad checksum: #{download_checksum}" if download_checksum != checksum
85+
86+
# extract - can't use Gem::Package#extract_tar_gz from RubyGems
87+
# since it limits filenames to 100 characters (doesn't support UStar format)
88+
# for space, only keep licenses, include, and shared library
9189
tar_args = Gem.win_platform? ? ["--force-local"] : []
9290
system "tar", "zxf", download_path, "-C", extract_path, "--strip-components=1", *tar_args
9391

0 commit comments

Comments
 (0)