Commit Graph

46 Commits

Author SHA1 Message Date
Robert Haines 03a9ee6b8a Rename `GPFBit3Error` to `StreamingError`.
`GPFBit3Error` doesn't really mean anything to the general user, and
it's not descriptive of the issue at hand. This error is raised when a
zip file cannot be streamed via `InputStream`, so `StreamingError` makes
more sense.

Also standardize the error message while we're about it.
2022-08-14 22:23:51 +01:00
Robert Haines 2e4dd9e0aa Improve the message for CompressionMethodError.
Convert the compression method number into a meaningful text
representation, e.g., "BZIP2" instead of "12".
2022-08-14 22:23:51 +01:00
Brian Williams 6f1ad8b37d Fix unraised error on encrypted archives 2022-08-09 22:11:42 +01:00
Robert Haines e07f019507 Improve the description of `InputStream#get_next_entry`.
Documentation now refects the fact that the stream is positioned at the start
of the entry data.
2022-04-23 13:52:50 +01:00
Robert Haines 66527ae10d Fix minor typo in `GPFBit3Error` message in `InputStream`. 2021-06-27 21:55:15 +01:00
Robert Haines 19e5f4a8ce Detect and raise GPFBit3Error in `InputStream.get_next_entry`.
We were previously trying to work out where the next entry would be,
even with GP bit 3 set, but the logic was flaky and cannot really be
correct given the data available. It's not expected behaviour, so raise
the error instead.

This means that we get rid of the incorrect `Entry.data_descriptor_size`
which was doing more harm than good.
2021-06-27 21:43:03 +01:00
Robert Haines aa646ef827 Use named params for `InputStream`. 2021-06-27 10:20:11 +01:00
Robert Haines 193507b15a Adjust Layout/LineLength cop to 100 characters.
We'll get the line length down in stages...
2021-06-25 22:31:34 +01:00
Robert Haines 84b3e8c644 Ensure `InputStream` raises `GPFBit3Error` for OSX Archive files.
Fixes #493.
2021-06-25 17:53:18 +01:00
Robert Haines 78565db40c Simplify `InputStream.open_entry`.
Also ensure `@complete_entry` is initialized!
2021-06-25 17:53:18 +01:00
Robert Haines e70e1d3080 Add `InputStream#size`.
This will enable `InputStream` to be used with external APIs that expect
to be able to query the expected size of data they will receive, such as
S3.

Fixes #451.
2021-05-26 13:35:16 +01:00
Robert Haines e10badf68e Fix Style/FrozenStringLiteralComment cop. 2021-05-25 21:24:50 +01:00
Robert Haines 5ce4e13ddd Configure and fix Style/ClassCheck cop. 2020-02-15 16:26:32 +00:00
Robert Haines cfe4972e71 Fix Layout/EmptyLineAfterGuardClause cop. 2020-02-15 16:26:32 +00:00
Robert Haines 98c6969c18 Fix Layout/SpaceAroundOperators cop. 2020-02-15 16:26:32 +00:00
Robert Haines 73e405acef Fix Security/Open cop errors. 2020-02-15 15:56:17 +00:00
Jan-Joost Spanjers a5d068d3e8 Support Decompressor plugins 2020-01-26 15:34:17 +01:00
Jan-Joost Spanjers c66277db58 Rename Decompressor#sysread to #read 2020-01-26 15:34:17 +01:00
Jan-Joost Spanjers b80ce3cc57 Make decryption generic for all compression methods
Now, STORED files can be decrypted, just like DEFLATED files.
2020-01-26 15:34:17 +01:00
Jan-Joost Spanjers 4e28f7286c Untangle encryption and decompression 2020-01-26 15:34:17 +01:00
Jan-Joost Spanjers 8f7c5caf29 Drop #produce_input from Decompressor class 2020-01-26 15:34:17 +01:00
Jan-Joost Spanjers 1b6aeb2cd0 Replace Decompressor#input_finished? with #eof 2020-01-26 15:34:17 +01:00
Jan-Joost Spanjers 4a4c553b1e Move :eof from InputStream to AbastractInputStream 2020-01-26 15:34:17 +01:00
Jan-Joost Spanjers e072c57beb Add Entry#incomplete? 2020-01-26 15:34:17 +01:00
Jan-Joost Spanjers c897bbdf77 Add Entry#encrypted? 2020-01-26 15:34:17 +01:00
Robert Haines 340379f080 Use `warn` instead of `puts` for messages from the library code.
`warn` has the advantage of easily being disabled by, the `-W0` interpreter
flag or setting $VERBOSE to nil.
2019-10-11 19:31:42 +01:00
Andrew Meyer c787d94852 Handle stored files with general purpose bit 3 set
Signed-off-by: Sam Coward <scoward@pivotal.io>
2018-04-03 16:07:18 -04:00
Phil ffd0b671b8 Fix regression caused by Rubocop cleanup
InputStream:

```
if @current_entry && @current_entry.gp_flags & 8 == 8 && @current_entry.crc == 0 \
  && @current_entry.compressed_size == 0 \
  && @current_entry.empty? && !@internal
```

`Zip::Entry#empty?` doesn't exist, but an automatic Rubocop check thought it should be converted from `size == 0`.

Unfortunately, this is tricky to write a test for as it only fails under some very specific conditions.
2018-02-23 13:22:57 -08:00
Takumasa Ochi cf91112b57 Apply automatic correction by rubocop 2017-06-29 11:57:12 +09:00
Seth Kingsley 05a9ba3f20 Use duck typing to detect IO-like objects. 2015-09-03 06:16:32 -07:00
Pavel Lobashov c0177a455b Merge branch 'master' into rubocop_fixes
Conflicts:
	README.md
	samples/example_recursive.rb
2015-06-08 10:14:25 +03:00
Alexander Simonov d289780072 Fix #234. Add special variable what is a flag about internal usege 2015-06-07 17:29:54 +03:00
Vít Ondruch 32016ab1bf Remove executable bit. 2015-03-31 13:15:46 +02:00
Pavel Lobashov d5f79822c1 fix rubocop Style/LineEndConcatenation cop 2015-03-23 19:03:28 +03:00
Pavel.Lobashov abf9cbec23 fix rubocop Style/RedundantSelf cop 2015-03-22 19:30:24 +03:00
Pavel Lobashov b730387cf2 redone fixes by rubocop Style/Alias to be in style of https://github.com/bbatsov/ruby-style-guide#alias-method-lexically 2015-03-21 13:14:21 +03:00
Pavel Lobashov b93ef1266f fix rubocop Style/StringLiterals cop 2015-03-21 11:27:44 +03:00
Pavel Lobashov 98e6b5d057 fix rubocop Style/AlignParameters cop 2015-03-21 10:44:56 +03:00
Pavel.Lobashov bb08213cb7 fix rubocop Style/Alias cop 2015-03-20 23:17:05 +03:00
Alexander Simonov 0cb838f019 Fix #221 2015-02-16 21:51:44 +02:00
Johnny Shields c2ecafe770 Change method interfaces to allow encrypter/decrypter to be passed into stream methods 2015-01-04 04:07:51 +09:00
Shigeaki Matsumura c70e5836c7 support traditional encryption 2015-01-01 11:09:17 +09:00
Alexander Simonov ec81c30382 Fix for #126 and #127 2014-01-24 11:37:38 +02:00
Alexander Simonov c7f0b17abf Real fix for #119 2014-01-19 13:45:58 +02:00
Alexander Simonov 73d9e1c8a0 StingIO support #47 #18 2013-08-29 23:50:12 +03:00
Alexander Simonov 61ce5dbc5f Refactoring part #2
Rubyzip interface was changed!
2013-06-03 10:56:24 +03:00