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

Replace zip with zip_next #128

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- `Release::asset_for` now searches for current `OS` and `ARCH` inside `asset.name` if `target` failed to match
- Update `reqwest` to `0.12.0`
- Update `hyper` to `1.2.0`
- Replace `zip` with `zip_next`
### Removed

## [0.39.0]
Expand Down
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ readme = "README.md"
authors = ["James Kominick <[email protected]>"]
exclude = ["/ci/*", ".travis.yml", "appveyor.yml"]
edition = "2018"
rust = "1.64"
rust-version = "1.67"

[dependencies]
serde_json = "1"
tempfile = "3"
flate2 = { version = "1", optional = true }
tar = { version = "0.4", optional = true }
semver = "1.0"
zip = { version = "0.6", default-features = false, features = ["time"], optional = true }
zip_next = { version = "1.0", default-features = false, features = ["time"], optional = true }
either = { version = "1", optional = true }
reqwest = { version = "0.12", default-features = false, features = ["blocking", "json"] }
hyper = "1"
Expand All @@ -32,9 +32,9 @@ zipsign-api = { version = "0.1.0-a.3", default-features = false, optional = true

[features]
default = ["reqwest/default-tls"]
archive-zip = ["zip", "zipsign-api?/verify-zip"]
compression-zip-bzip2 = ["archive-zip", "zip/bzip2"]
compression-zip-deflate = ["archive-zip", "zip/deflate"]
archive-zip = ["zip_next", "zipsign-api?/verify-zip"]
compression-zip-bzip2 = ["archive-zip", "zip_next/bzip2"]
compression-zip-deflate = ["archive-zip", "zip_next/deflate"]
archive-tar = ["tar", "zipsign-api?/verify-tar"]
compression-flate2 = ["archive-tar", "flate2", "either"]
rustls = ["reqwest/rustls-tls"]
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ which runs something roughly equivalent to:
```rust
use self_update::cargo_crate_version;

fn update() -> Result<(), Box<::std::error::Error>> {
fn update() -> Result<(), Box<dyn ::std::error::Error>> {
let status = self_update::backends::github::Update::configure()
.repo_owner("jaemk")
.repo_name("self_update")
Expand All @@ -70,7 +70,7 @@ and any file not matching the format, or not matching the provided prefix string
```rust
use self_update::cargo_crate_version;

fn update() -> Result<(), Box<::std::error::Error>> {
fn update() -> Result<(), Box<dyn ::std::error::Error>> {
let status = self_update::backends::s3::Update::configure()
.bucket_name("self_update_releases")
.asset_prefix("something/self_update")
Expand Down
2 changes: 1 addition & 1 deletion src/backends/gitea.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ gitea releases
use std::env::{self, consts::EXE_SUFFIX};
use std::path::{Path, PathBuf};

use reqwest::{self, header};
use reqwest::header;

use crate::backends::find_rel_next_link;
use crate::{
Expand Down
4 changes: 2 additions & 2 deletions src/backends/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use hyper::HeaderMap;
use std::env::{self, consts::EXE_SUFFIX};
use std::path::{Path, PathBuf};

use reqwest::{self, header};
use reqwest::header;

use crate::backends::find_rel_next_link;
use crate::{
Expand Down Expand Up @@ -348,7 +348,7 @@ impl UpdateBuilder {
///
/// ```
/// # use self_update::backends::github::Update;
/// # fn run() -> Result<(), Box<::std::error::Error>> {
/// # fn run() -> Result<(), Box<dyn ::std::error::Error>> {
/// Update::configure()
/// .bin_path_in_archive("bin/myapp")
/// # .build()?;
Expand Down
6 changes: 3 additions & 3 deletions src/backends/gitlab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Gitlab releases
use std::env::{self, consts::EXE_SUFFIX};
use std::path::{Path, PathBuf};

use reqwest::{self, header};
use reqwest::header;

use crate::backends::find_rel_next_link;
use crate::{
Expand Down Expand Up @@ -72,7 +72,7 @@ pub struct ReleaseListBuilder {
impl ReleaseListBuilder {
/// Set the gitlab `host` url
pub fn with_host(&mut self, host: &str) -> &mut Self {
self.host = host.to_owned();
host.clone_into(&mut self.host);
self
}

Expand Down Expand Up @@ -250,7 +250,7 @@ impl UpdateBuilder {

/// Set the gitlab `host` url
pub fn with_host(&mut self, host: &str) -> &mut Self {
self.host = host.to_owned();
host.clone_into(&mut self.host);
self
}

Expand Down
4 changes: 2 additions & 2 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Error type, conversions, and macros

*/
#[cfg(feature = "archive-zip")]
use zip::result::ZipError;
use zip_next::result::ZipError;

pub type Result<T> = std::result::Result<T, Error>;

Expand Down Expand Up @@ -48,7 +48,7 @@ impl std::fmt::Display for Error {
write!(f, "No signature verification implemented for {:?} files", kind)
}
#[cfg(feature = "signatures")]
Signature(ref e) => write!(f, "SignatureError: {}", e),
Signature(ref e) => write!(f, "SignatureError: {:?}", e),
#[cfg(feature = "signatures")]
NonUTF8 => write!(f, "Cannot verify signature of a file with a non-UTF-8 name"),
}
Expand Down
24 changes: 13 additions & 11 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![cfg_attr(feature = "cargo-clippy", deny(clippy::all))]
#![deny(clippy::all)]
/*!

[![Build status](https://ci.appveyor.com/api/projects/status/xlkq8rd73cla4ixw/branch/master?svg=true)](https://ci.appveyor.com/project/jaemk/self-update/branch/master)
Expand Down Expand Up @@ -47,7 +47,7 @@ which runs something roughly equivalent to:
```rust
use self_update::cargo_crate_version;

fn update() -> Result<(), Box<::std::error::Error>> {
fn update() -> Result<(), Box<dyn ::std::error::Error>> {
let status = self_update::backends::github::Update::configure()
.repo_owner("jaemk")
.repo_name("self_update")
Expand All @@ -70,7 +70,7 @@ and any file not matching the format, or not matching the provided prefix string
```rust
use self_update::cargo_crate_version;

fn update() -> Result<(), Box<::std::error::Error>> {
fn update() -> Result<(), Box<dyn ::std::error::Error>> {
let status = self_update::backends::s3::Update::configure()
.bucket_name("self_update_releases")
.asset_prefix("something/self_update")
Expand Down Expand Up @@ -415,7 +415,7 @@ impl<'a> Extract<'a> {
}
#[cfg(feature = "archive-zip")]
ArchiveKind::Zip => {
let mut archive = zip::ZipArchive::new(source)?;
let mut archive = zip_next::ZipArchive::new(source)?;
for i in 0..archive.len() {
let mut file = archive.by_index(i)?;

Expand Down Expand Up @@ -520,8 +520,10 @@ impl<'a> Extract<'a> {
}
#[cfg(feature = "archive-zip")]
ArchiveKind::Zip => {
let mut archive = zip::ZipArchive::new(source)?;
let mut file = archive.by_name(file_to_extract.to_str().unwrap())?;
let mut archive = zip_next::ZipArchive::new(source)?;
let mut file = archive
.by_name(file_to_extract.to_str().unwrap())
.map_err(Error::Zip)?;

let output_path = into_dir.join(file.name());
if let Some(parent_dir) = output_path.parent() {
Expand Down Expand Up @@ -745,7 +747,7 @@ impl Download {
mod tests {
use super::*;
#[cfg(feature = "compression-flate2")]
use flate2::{self, write::GzEncoder};
use flate2::write::GzEncoder;
#[allow(unused_imports)]
use std::{
fs::{self, File},
Expand Down Expand Up @@ -1084,10 +1086,10 @@ mod tests {

#[cfg(feature = "archive-zip")]
ArchiveKind::Zip => {
let mut zip = zip::ZipWriter::new(archive_file);
let options = zip::write::FileOptions::default()
.compression_method(zip::CompressionMethod::Stored);
zip.start_file("temp.txt", options)
let mut zip = zip_next::ZipWriter::new(archive_file);
let options = zip_next::write::FileOptions::default()
.compression_method(zip_next::CompressionMethod::Stored);
zip.start_file("temp.txt", options.clone())
.expect("failed starting zip file");
zip.write_all(b"This is a test!")
.expect("failed writing to zip");
Expand Down
2 changes: 1 addition & 1 deletion src/update.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use reqwest::{self, header};
use reqwest::header;
use std::env::consts::{ARCH, OS};
use std::fs;
use std::path::PathBuf;
Expand Down