Commit graph

230 commits

Author SHA1 Message Date
Chris Hennick
b7f4bd6faf
Minor refactor 2023-04-25 15:06:11 -07:00
Chris Hennick
36e7b19969
Add deep-copy method, and include copying in end-to-end tests 2023-04-24 10:44:36 -07:00
Chris Hennick
3b3b63cef5
Fix a flaky test 2023-04-23 15:14:44 -07:00
Chris Hennick
6dc099d128
Fix more formatting issues 2023-04-23 15:12:56 -07:00
Chris Hennick
9330bdb7b7
Don't need Read for shallow copy 2023-04-23 15:09:22 -07:00
Chris Hennick
d3400509bc
Fix formatting issues from cargo fmt 2023-04-23 14:58:10 -07:00
Chris Hennick
7e7483ef5c
Remove unnecessary package qualifiers 2023-04-23 14:52:14 -07:00
Chris Hennick
360a7de003
Fix clippy warning: use write_all instead of write 2023-04-23 14:51:17 -07:00
Chris Hennick
cde5d5ed11
Implement shallow copy from within the file being written 2023-04-23 14:33:10 -07:00
Marli Frost
0a09253896 docs: clarify how to use the add_directory API
closes #323
2023-02-01 17:23:53 +00:00
Marli Frost
42eabc9e33 fix: update references to old from_time API 2023-02-01 14:01:53 +00:00
Kyle Bloom
5726a07a76 feat: Move from_time to try_from
Moves from_time function to TryFrom<OffsetDateTime>
2023-02-01 13:58:15 +00:00
Kyle Bloom
503eda67c3 fix: Clippy should implement trait 2023-01-31 17:36:06 +00:00
Kyle Bloom
03f5009c34 fix: Clippy uninlined format args 2023-01-31 17:29:34 +00:00
Wyatt Herkamp
d59adf0990 Fixed new Clippy Warnings 2022-10-13 07:44:25 -04:00
Dirk Stolle
e3d8f47708 Fix a few typos 2022-05-01 00:39:24 +02:00
Gregory Szorc
46c2ae88d4 Implement support for writing symlinks
The primary goal of this commit is to enable this library to emit
zip archives with symlinks while minimizing the surface area of the
change to hopefully enable the PR to merge with minimal controversy.

Today, it isn't possible to write symlinks with this library because
there's no way to preserve the upper S_IFMT bits in the file mode
bits because:

* There's no way to set FileOptions.permissions with the S_IFLNK bits
  set (FileOptions.unix_permissions() throws away bits beyond 0o777).
* Existing APIs for starting a "typed" (e.g. file or directory) entry
  automatically set the S_IFMT bits and could conflict with bits
  set on FileOptions.permissions.
* The low-level, generic start_entry() function isn't public.

When implementing this, I initially added a `FileOptions.unix_mode()`
function to allow setting all 16 bits in the eventual external
attributes u32. However, I quickly realized this wouldn't be enough
because APIs like start_file() do things like `|= 0o100000`. So if
we went this route, we'd need to make consumers of
FileOptions.permissions aware of when they should or shouldn't touch
the high bits beyond 0o777.

I briefly thought about making FileOptions.permissions an enum with
a variant to allow the st_mode bits to sail through unmodified. But
this change seemed overly invasive, low level, and not very
user-friendly.

So the approach I decided on was to define a new add_symlink() API.
It follows the pattern of add_directory() and provides an easy-to-use
and opionated API around the addition of a special file type.

I purposefully chose to not implement reading or extraction support
for symlinks because a) I don't need the feature at the moment
b) implementing symlink extraction in a way that works reliably on all
platforms and doesn't have security issues is hard. I figured it was
best to limit the scope of this change so this PR stands a good chance
of being merged.

Partially implements #77.
2022-04-12 10:58:24 -07:00
Pieter-Jan Briers
6b5628bef4 Use Seek.stream_position instead of seek(0).
BufReader can cache the result of stream_position() so it's fast, whereas seek(0) discards the read buffer and passes through straight to the OS. This drastically worsens the efficiency of loading performance when using BufReader (or anything else to avoid all these tiny reads going straight to the kernel).
2022-04-11 14:30:27 +02:00
Rouven Spreckels
9a32d129ff Fix build with --no-default-features. 2022-03-28 11:43:25 +02:00
Alexander Zaitsev
77294fd3ce
Revert "Merge pull request #290 from aweinstock314/more-spec-structs"
This reverts commit a1da6860ea, reversing
changes made to 574bb3df17.
2022-03-26 14:13:50 +03:00
Avi Weinstock
45a98c01b9 Cargo fmt and cargo clippy fixes. 2022-03-25 14:10:44 -04:00
Avi Weinstock
993cbcdc5c Add zip::spec::{CentralDirectoryHeader, DataDescriptor, LocalFileHeader}, and partially integrate them into zip::{read, write}. 2022-03-25 14:10:10 -04:00
Rouven Spreckels
00c1199dbe Use ZIP64_BYTES_THR and ZIP64_ENTRY_THR. 2022-03-25 16:01:56 +01:00
Rouven Spreckels
e9706ae4f5 Fix ZIP64 write support. 2022-03-25 12:53:18 +01:00
Дмитрий Кальянов
e8dabec5b6 Add support for specifying compression level 2022-03-23 13:06:28 +03:00
Alexander Zaitsev
ca60821c0a merge: Merge branch 'master' into explainer 2022-03-08 18:13:34 +03:00
Benoît du Garreau
addfe01eb0 Make ZipArchive cheap to clone 2022-02-05 16:08:55 +01:00
Lireer
8f061f882b fix nightly clippy warning 2022-01-30 15:26:34 +01:00
Lireer
49f7501c5f add and use AES associated constant 2022-01-30 15:10:07 +01:00
Lireer
d7f0a182b6 Merge remote-tracking branch 'zip-rs/zip/master' 2022-01-25 17:48:45 +01:00
Marli Frost
f1074bc6a9 doc: remove re-exports section from crate root
Making the paths to the types private forces rustdoc to render
the structs inline in the crate root.
This is simpler to see when first reading the API doc
2022-01-23 21:45:41 +00:00
Alexander Zaitsev
5a4ca9557c fix: permissions are not copied
- fix a small bug when permissions where not copied
- add must_use attribute to the all FileOptions methods

Tested:
- No
2022-01-23 20:16:01 +03:00
Alexander Zaitsev
63e714f622 Merge branch 'master' into feature/add_zstd_compression 2022-01-23 19:17:26 +03:00
Alexander Zaitsev
e636399935 fix: fix all Clippy warnings
- some warnings are muted since fixing them right now can be a breaking
  API change
- fix Clippy warns in the src, examples and tests

Tested:
- Local test run
2022-01-23 18:54:43 +03:00
Alexander Zaitsev
061cdf149f fix: fix Clippy warnings
- fix a bunch of Clippy warnings
- fix some usages of assert! (change to assert_ne)

Tested:
- Local unit-tests run
2022-01-23 17:35:27 +03:00
Alexander Zaitsev
0b82d905b3 feat: add Zstandard compression
- add dependency on zstd crate
- add zstd feature to Cargo.toml
- update README
- update example with Zstd
- add Zstd support to the library

Notes:
- This work is mainly based on this original PR: https://github.com/zip-rs/zip/pull/240

Tested:
- During the development of the original PR
2022-01-23 14:49:48 +03:00
Steve Myers
2f71810c07
Upgrade time dependency to "0.3"
Versions of time crate prior to 0.2.23 fail audit due to RUSTSEC-2020-0071.

Crate: time
Version: 0.1.43
Title: Potential segfault in the time crate
Date: 2020-11-18
ID: RUSTSEC-2020-0071
URL: https://rustsec.org/advisories/RUSTSEC-2020-0071
Solution: Upgrade to >=0.2.23
2021-10-21 21:31:37 -07:00
Lireer
75e8f6bab5 use less feature gates if no further dependencies are needed 2021-08-06 12:38:04 +02:00
Lireer
48b52a7e86 move AesMode and AesVendorVersion out of aes-crypto feature 2021-08-05 21:16:11 +02:00
Lireer
354993d906 feature gate aes decryption 2021-08-05 21:06:47 +02:00
Lireer
852ab625fb initial aes reader 2021-08-04 19:02:22 +02:00
Marli Frost
3fd44ffd5d
Merge pull request #200 from qu1x/support-extra-field 2021-05-11 11:18:17 +01:00
Benjamin Richner
80f4c43369 Add Info-ZIP password validation 2021-05-02 04:02:50 +02:00
Marli Frost
8ecbdb1870
chore: update to bzip 0.4 2021-04-19 12:29:19 +01:00
Marli Frost
44352aa34b
fix: allow non-utf8 comments in ZipWriter 2021-04-19 12:02:32 +01:00
zhanghar
32b2f5b483 refactor: use iterator for file list init 2021-02-25 23:54:20 -05:00
Rouven Spreckels
129d7301ef Note that large_file() requires ZIP64 support. 2021-02-07 12:46:52 +01:00
zhanghar
10da026ff6 feat: support append to an existing archive 2020-12-23 14:37:09 -05:00
Rouven Spreckels
425c54cd5f Fix updating local ZIP64 extra field. 2020-11-18 16:27:28 +01:00
Rouven Spreckels
d53c8bdf07 Merge branch 'master' into support-extra-field 2020-11-16 11:57:08 +01:00