Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds unzip module #53

Merged
merged 6 commits into from
Nov 3, 2020
Merged

Adds unzip module #53

merged 6 commits into from
Nov 3, 2020

Conversation

Cyberboss
Copy link
Member

@Cyberboss Cyberboss commented Oct 24, 2020

Allows downloading and extracting zips from urls

Closes #50

Needed for out of repo maps

Allows downloading and extracting zips from urls
@Cyberboss
Copy link
Member Author

Proof in pudding
image

src/unzip.rs Outdated Show resolved Hide resolved
let reader = std::io::Cursor::new(content);
let mut archive = ZipArchive::new(reader)?;

for i in 0..archive.len()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm kinda dumbfounded that there's no Iterator for this. oh well

Copy link
Contributor

@vuonojenmustaturska vuonojenmustaturska Oct 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Felt weird to me so I looked it up, https://users.rust-lang.org/t/is-it-possible-to-create-an-iterator-for-ziparchive-in-zip-crate/5744/3

tldr you can’t make an Iterator that takes a ZipArchive and yields ZipFile items. This is because a ZipFile mutably borrows the ZipArchive's reader, so a single archive can only have one ZipFile at a time.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spooky! 👻

src/unzip.rs Outdated Show resolved Hide resolved
Co-authored-by: Rohesie <rohesie@gmail.com>
@Cyberboss
Copy link
Member Author

@tgstation/rust-g-dev-team meep

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Function to download and unzip a .zip file from a given url.
5 participants