Commit Graph

24 Commits

Author SHA1 Message Date
Robert Haines 58f053afb0 Only use the Zip64 CDIR end locator if needed.
Previously the central directory Zip64 data was written even if it wasn't
strictly needed. The standard allows for entries to include Zip64 data
(say, if they are streamed and their size is unknown when writing the file
data) without needing any Zip64 data in the central directory. So now we
only write central directory Zip64 data if there are over 65535 files or
the file data is huge.
2023-01-03 20:19:40 +00:00
Robert Haines f460da3afb Prevent unnecessary Zip64 data being stored.
With Zip64 write support enabled by default, it's important that we
only store the extra data when we need to. This commit ensures that
the Zip64 extra data is included for an entry if its size is over
4GB, or if we don't know how big it will be at the point of writing
the local header data.

This commit also removes the need for the Zip64Placeholder extra
data field. Now we just use the Zip64 field itself and ensure it's
filled in correctly.
2023-01-03 20:19:40 +00:00
Robert Haines bdbd573290 Remove unnecessary static method from `CentralDirectory`.
`CentralDirectory` shouldn't be in the public API for rubyzip and
there's nothing that `CentralDirectory::read_from_stream` did that
couldn't be done by just initializing an object first. Keeping it around
risked things getting out of date as we streamline and fix other things.
2022-01-17 18:10:17 +00:00
Robert Haines f5e19db273 Add a 100,000 file zip to test `count_entries`. 2021-11-20 20:02:47 +00:00
Robert Haines 3db1eff1e3 Add `CentralDirectory#count_entries`.
This method gets the number of entries from a zip archive without
loading all of the individual entries.
2021-11-20 10:50:55 +00:00
Robert Haines afe1892208 Fix a mis-firing CentralDirectory test.
`test_read_from_truncated_zip_file` was not testing what it thought it
was. It was testing whether we caught an out-of-bounds cdir offset, not
whether we caught a corrupted cdir entry.

This commit embraces the actual behaviour and tests that we catch an
out-of-bounds error for both standard `IO`s and `StringIO`s.
2021-06-18 11:44:58 +01:00
Robert Haines e10badf68e Fix Style/FrozenStringLiteralComment cop. 2021-05-25 21:24:50 +01:00
Oleksandr Simonov b6eae4f9d8
Merge pull request #468 from bbuchalter/remove_compare_enumerables
Remove compare_enumerables from test_helper.rb
2021-02-14 14:28:19 +02:00
Brian Buchalter 72cedd7ce4 Remove compare_enumerables from test_helper.rb
This change has several benefits:
* When errors occur, the test provides useful feedback, showing you
  expected vs. actual.
* We no longer need to open and modify the Enumerable module.
* The test is more readable.
2021-01-26 06:19:26 -07:00
Robert Haines e4ceedaa58 Use keyword arguments for the `Entry` initializer.
This greatly simplifies the creation of `Entry` objects when only a
couple of fields are not set to their defaults, while at the same time
allowing an `Entry` to be fully configured at creation time if
appropriate.

This fundamentally changes the `Entry` API and  means that some
convenience methods in `OutputStream` and `File` have needed to be
refactored.
2020-08-31 17:48:08 +01:00
Robert Haines e6f414f539 Fix Naming/VariableName cop in the tests. 2020-02-29 18:11:52 +00:00
Robert Haines 846e704048 Fix Naming/BlockParameterName cop. 2020-02-17 22:35:08 +00:00
Robert Haines 2cbdbf110b Fix Style/SignalException cop. 2020-02-15 16:26:32 +00:00
Pavel Lobashov 23cfcc73b5 fix rubocop Style/MethodName cop 2015-03-24 19:02:54 +03:00
Pavel Lobashov 1ba81ff46f fix rubocop Style/NumericLiterals cop 2015-03-23 19:23:04 +03:00
Pavel.Lobashov 8d6f23ba9a fix rubocop Style/SpaceAroundOperators cop 2015-03-22 20:03:50 +03:00
Pavel Lobashov b93ef1266f fix rubocop Style/StringLiterals cop 2015-03-21 11:27:44 +03:00
Pavel Lobashov b9a757e045 fix rubocop Style/EmptyLinesAroundClassBody cop 2015-03-21 11:21:26 +03:00
Pavel Lobashov d2d8590ef8 fix rubocop Style/Blocks cop 2015-03-21 11:10:37 +03:00
Jason King 96f84aee4c Fixes occasional failures of tests 2014-07-24 11:34:55 -07:00
Robert Haines 9785b66a43 Update tests to use the minitest 5.x API.
MiniTest::Unit::TestCase -> MiniTest::Test
MiniTest::Unit.after_tests -> MiniTest.after_run
2014-07-23 12:59:13 +03:00
Alexander Simonov ec81c30382 Fix for #126 and #127 2014-01-24 11:37:38 +02:00
Alexander Simonov 541ff9657f Move file generation to one folder 2014-01-20 23:42:27 +02:00
Alexander Simonov 58f08ca0e1 Split all tests to small files. Move to minitest 2014-01-20 23:31:06 +02:00