Skip to content

A platform for community discussion. Free, open, simple.

DEV: Update rubyzip to 3.x (attempt 2) (#39151)

Jarek Radoszd4246c4bba55
diff --git a/Gemfile b/Gemfile
index 7ce1d647c7c..b7f47a31c01 100644
--- a/Gemfile
+++ b/Gemfile
@@ -224,8 +224,7 @@ gem "rotp", require: false
gem "rqrcode"
-# can't upgrade to 3.x due to d-token-gate
-gem "rubyzip", "~> 2.0", require: false
+gem "rubyzip", require: false
gem "sshkey", require: false
diff --git a/Gemfile.lock b/Gemfile.lock
index ae20c63d1f8..ef4381028b1 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -624,7 +624,7 @@ GEM
guess_html_encoding (>= 0.0.4)
nokogiri (>= 1.6.0)
ruby2_keywords (0.0.5)
- rubyzip (2.4.1)
+ rubyzip (3.2.2)
sanitize (7.0.0)
crass (~> 1.0.2)
nokogiri (>= 1.16.8)
@@ -902,7 +902,7 @@ DEPENDENCIES
ruby-progressbar
ruby-rc4
ruby-readability
- rubyzip (~> 2.0)
+ rubyzip
sanitize
sassc-embedded
sawyer
@@ -1207,7 +1207,7 @@ CHECKSUMS
ruby-rc4 (0.1.5) sha256=00cc40a39d20b53f5459e7ea006a92cf584e9bc275e2a6f7aa1515510e896c03
ruby-readability (0.7.3) sha256=bd213fab037118cc15d999e167a8ea2cc6b689dc78c033e78fb36a2a37efc241
ruby2_keywords (0.0.5) sha256=ffd13740c573b7301cf7a2e61fc857b2a8e3d3aff32545d6f8300d8bae10e3ef
- rubyzip (2.4.1) sha256=8577c88edc1fde8935eb91064c5cb1aef9ad5494b940cf19c775ee833e075615
+ rubyzip (3.2.2) sha256=c0ed99385f0625415c8f05bcae33fe649ed2952894a95ff8b08f26ca57ea5b3c
sanitize (7.0.0) sha256=269d1b9d7326e69307723af5643ec032ff86ad616e72a3b36d301ac75a273984
sass-embedded (1.91.0-aarch64-linux-gnu) sha256=932bf7223ffbbdeefc91cd364de6bf9dbfdc7d80201911eb4dae8d9a7f5bee50
sass-embedded (1.91.0-aarch64-linux-musl) sha256=08449fac861094055a1afe7da376f887f8192b3dba6658db1de7be17d32355c4
diff --git a/lib/compression/gzip.rb b/lib/compression/gzip.rb
index f32836f957e..7df4b9d240c 100644
--- a/lib/compression/gzip.rb
+++ b/lib/compression/gzip.rb
@@ -50,7 +50,7 @@ module Compression
remaining_size = available_size
if ::File.exist?(entry_path)
- raise ::Zip::DestinationFileExistsError, "Destination '#{entry_path}' already exists"
+ raise DestinationFileExistsError, "Destination '#{entry_path}' already exists"
end # Change this later.
::File.open(entry_path, "wb") do |os|
diff --git a/lib/compression/zip.rb b/lib/compression/zip.rb
index dbf132bf880..ccfe4096d34 100644
--- a/lib/compression/zip.rb
+++ b/lib/compression/zip.rb
@@ -12,7 +12,7 @@ module Compression
absolute_path = sanitize_path("#{path}/#{target_name}")
zip_filename = "#{absolute_path}.zip"
- ::Zip::File.open(zip_filename, ::Zip::File::CREATE) do |zipfile|
+ ::Zip::File.open(zip_filename, create: true) do |zipfile|
if File.directory?(absolute_path)
entries = Dir.entries(absolute_path) - %w[. ..]
write_entries(entries, absolute_path, "", zipfile)
@@ -27,7 +27,7 @@ module Compression
private
def extract_folder(entry, entry_path)
- entry.extract(entry_path)
+ FileUtils.mkdir_p(entry_path)
end
def get_compressed_file_stream(compressed_file_path)
@@ -47,7 +47,7 @@ module Compression
remaining_size = available_size
if ::File.exist?(entry_path)
- raise ::Zip::DestinationFileExistsError, "Destination '#{entry_path}' already exists"
+ raise DestinationFileExistsError, "Destination '#{entry_path}' already exists"
end
::File.open(entry_path, "wb") do |os|
diff --git a/spec/system/page_objects/pages/csv_export_pm.rb b/spec/system/page_objects/pages/csv_export_pm.rb
index 7260ee6e918..2c73dc380dd 100644
--- a/spec/system/page_objects/pages/csv_export_pm.rb
+++ b/spec/system/page_objects/pages/csv_export_pm.rb
@@ -36,9 +36,8 @@ module PageObjects
paths = []
Zip::File.open(file) do |zip_file|
zip_file.each do |f|
- path = File.join(Downloads::FOLDER, f.name)
- zip_file.extract(f, path)
- paths << path
+ f.extract(f.name, destination_directory: Downloads::FOLDER)
+ paths << File.join(Downloads::FOLDER, f.name)
end
end