From 2ba2ef1b9c0b3e00c9096710e1c67dabc730b3e2 Mon Sep 17 00:00:00 2001 From: Sandip Trivedi Date: Wed, 27 May 2015 18:09:22 -0400 Subject: [PATCH 1/2] Replaces the zipzip gem with the rubyzip gem --- Gemfile | 6 +++--- Gemfile.lock | 4 +--- app/models/user.rb | 2 +- config/initializers/rubyzip.rb | 7 +++++++ spec/models/user_spec.rb | 4 ++-- 5 files changed, 14 insertions(+), 9 deletions(-) create mode 100644 config/initializers/rubyzip.rb diff --git a/Gemfile b/Gemfile index 7ee8c409cae..5820c088792 100644 --- a/Gemfile +++ b/Gemfile @@ -173,9 +173,9 @@ gem "rails-timeago", "2.11.0" gem "logging-rails", "0.5.0", require: "logging/rails" -# Workarounds -# https://github.com/rubyzip/rubyzip#important-note -gem "zip-zip" +# # Workarounds +# # https://github.com/rubyzip/rubyzip#important-note +gem "rubyzip" # Prevent occasions where minitest is not bundled in # packaged versions of ruby. See following issues/prs: diff --git a/Gemfile.lock b/Gemfile.lock index 47b1b501aa4..e9d965d52cf 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -718,8 +718,6 @@ GEM will_paginate (3.0.7) xpath (2.0.0) nokogiri (~> 1.3) - zip-zip (0.3) - rubyzip (>= 1.0.0) PLATFORMS ruby @@ -830,6 +828,7 @@ DEPENDENCIES rspec-rails (= 3.2.1) rubocop (= 0.31.0) ruby-oembed (= 0.8.14) + rubyzip sass-rails (= 5.0.1) selenium-webdriver (= 2.45.0) shoulda-matchers (= 2.8.0) @@ -851,4 +850,3 @@ DEPENDENCIES uuid (= 2.3.7) webmock (= 1.21.0) will_paginate (= 3.0.7) - zip-zip diff --git a/app/models/user.rb b/app/models/user.rb index a2a5faabbd5..364a33350d3 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -325,7 +325,7 @@ def queue_export_photos def perform_export_photos! temp_zip = Tempfile.new([username, '_photos.zip']) begin - Zip::ZipOutputStream.open(temp_zip.path) do |zos| + Zip::OutputStream.open(temp_zip.path) do |zos| photos.each do |photo| begin photo_file = photo.unprocessed_image.file diff --git a/config/initializers/rubyzip.rb b/config/initializers/rubyzip.rb new file mode 100644 index 00000000000..00b352494e5 --- /dev/null +++ b/config/initializers/rubyzip.rb @@ -0,0 +1,7 @@ +# https://github.com/rubyzip/rubyzip#configuration +# Zip.setup do |c| +# c.on_exists_proc = true +# c.continue_on_exists_proc = true +# c.unicode_names = true +# c.default_compression = Zlib::BEST_COMPRESSION +# end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 3a95098c318..517cacd856c 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1065,14 +1065,14 @@ expect(@user.exported_photos_at).to be_present expect(@user.exporting_photos).to be_falsey expect(@user.exported_photos_file.filename).to match /.zip/ - expect(Zip::ZipFile.open(@user.exported_photos_file.path).entries.count).to eq(1) + expect(Zip::File.open(@user.exported_photos_file.path).entries.count).to eq(1) end it "does not add empty entries when photo not found" do File.unlink @user.photos.first.unprocessed_image.path @user.perform_export_photos! expect(@user.exported_photos_file.filename).to match /.zip/ - expect(Zip::ZipFile.open(@user.exported_photos_file.path).entries.count).to eq(0) + expect(Zip::File.open(@user.exported_photos_file.path).entries.count).to eq(0) end end From 36d6c5d2ba2fa71ddad396e19c8c42051cab14ee Mon Sep 17 00:00:00 2001 From: Sandip Trivedi Date: Wed, 27 May 2015 20:48:05 -0400 Subject: [PATCH 2/2] Remove unnecessary initializer and comments in Gemfile and add explicit rubyzip gem version in Gemfile with description closes #6001 --- Changelog.md | 1 + Gemfile | 6 +++--- Gemfile.lock | 2 +- config/initializers/rubyzip.rb | 7 ------- 4 files changed, 5 insertions(+), 11 deletions(-) delete mode 100644 config/initializers/rubyzip.rb diff --git a/Changelog.md b/Changelog.md index 2b157e13483..790489e191f 100644 --- a/Changelog.md +++ b/Changelog.md @@ -18,6 +18,7 @@ * Improve the logging messages of Sidekiq messages [#5988](https://github.com/diaspora/diaspora/pull/5988) * Improve the logging of Eyes output [#5989](https://github.com/diaspora/diaspora/pull/5989) * Gracefully handle XML parse errors within federation [#5991](https://github.com/diaspora/diaspora/pull/5991) +* Remove zip-zip workaround gem [#6001](https://github.com/diaspora/diaspora/pull/6001) ## Bug fixes * Disable auto follow back on aspect deletion [#5846](https://github.com/diaspora/diaspora/pull/5846) diff --git a/Gemfile b/Gemfile index 5820c088792..537928c8028 100644 --- a/Gemfile +++ b/Gemfile @@ -173,9 +173,9 @@ gem "rails-timeago", "2.11.0" gem "logging-rails", "0.5.0", require: "logging/rails" -# # Workarounds -# # https://github.com/rubyzip/rubyzip#important-note -gem "rubyzip" +# Reading and writing zip files + +gem "rubyzip", "1.1.7" # Prevent occasions where minitest is not bundled in # packaged versions of ruby. See following issues/prs: diff --git a/Gemfile.lock b/Gemfile.lock index e9d965d52cf..cfd7d8e8d58 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -828,7 +828,7 @@ DEPENDENCIES rspec-rails (= 3.2.1) rubocop (= 0.31.0) ruby-oembed (= 0.8.14) - rubyzip + rubyzip (= 1.1.7) sass-rails (= 5.0.1) selenium-webdriver (= 2.45.0) shoulda-matchers (= 2.8.0) diff --git a/config/initializers/rubyzip.rb b/config/initializers/rubyzip.rb deleted file mode 100644 index 00b352494e5..00000000000 --- a/config/initializers/rubyzip.rb +++ /dev/null @@ -1,7 +0,0 @@ -# https://github.com/rubyzip/rubyzip#configuration -# Zip.setup do |c| -# c.on_exists_proc = true -# c.continue_on_exists_proc = true -# c.unicode_names = true -# c.default_compression = Zlib::BEST_COMPRESSION -# end