From 3622e8f68243706091ecb7e42cf2d554985b95d9 Mon Sep 17 00:00:00 2001 From: Wyatt Herkamp Date: Mon, 12 Sep 2022 10:26:39 -0400 Subject: [PATCH 1/9] hopefully a depend fix --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index f87f023b..439dca88 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ hmac = { version = "0.12.1", optional = true, features = ["reset"] } pbkdf2 = {version = "0.11.0", optional = true } sha1 = {version = "0.10.1", optional = true } time = { version = "0.3.7", features = ["formatting", "macros" ], optional = true } -zstd = { version = "0.11.0", optional = true } +zstd = { version = "0.11", optional = true } [target.'cfg(any(all(target_arch = "arm", target_pointer_width = "32"), target_arch = "mips", target_arch = "powerpc"))'.dependencies] crossbeam-utils = "0.8.8" From 13084ef73276adc49bc5f8d3f50608aaa633604f Mon Sep 17 00:00:00 2001 From: Wyatt Herkamp Date: Mon, 12 Sep 2022 18:53:15 -0400 Subject: [PATCH 2/9] Make github ci use 1.59 for time depend and fix two clippy warnings --- .github/workflows/ci.yaml | 2 +- src/types.rs | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 83004438..35d4a6e9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -16,7 +16,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macOS-latest, windows-latest] - rust: [stable, 1.57.0] + rust: [stable, 1.59.0] steps: - uses: actions/checkout@master diff --git a/src/types.rs b/src/types.rs index b65fad40..9b3b00c4 100644 --- a/src/types.rs +++ b/src/types.rs @@ -44,7 +44,7 @@ mod atomic { #[cfg(feature = "time")] use time::{error::ComponentRange, Date, Month, OffsetDateTime, PrimitiveDateTime, Time}; -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum System { Dos = 0, Unix = 3, @@ -143,10 +143,8 @@ impl DateTime { second: u8, ) -> Result { if (1980..=2107).contains(&year) - && month >= 1 - && month <= 12 - && day >= 1 - && day <= 31 + && (1..=12).contains(&month) + && (1..=31).contains(&day) && hour <= 23 && minute <= 59 && second <= 60 From 89e84e1032ebcf12ad849ad34ae7aa9fe700f940 Mon Sep 17 00:00:00 2001 From: Wyatt Herkamp Date: Tue, 27 Sep 2022 13:30:55 -0400 Subject: [PATCH 3/9] Fixed new Clippy Warnings --- src/read.rs | 8 ++++---- src/write.rs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/read.rs b/src/read.rs index 728ddf57..32403fa0 100644 --- a/src/read.rs +++ b/src/read.rs @@ -461,7 +461,7 @@ impl ZipArchive { } else { if let Some(p) = outpath.parent() { if !p.exists() { - fs::create_dir_all(&p)?; + fs::create_dir_all(p)?; } } let mut outfile = fs::File::create(&outpath)?; @@ -681,11 +681,11 @@ pub(crate) fn central_header_to_zip_file( reader.read_exact(&mut file_comment_raw)?; let file_name = match is_utf8 { - true => String::from_utf8_lossy(&*file_name_raw).into_owned(), + true => String::from_utf8_lossy(&file_name_raw).into_owned(), false => file_name_raw.clone().from_cp437(), }; let file_comment = match is_utf8 { - true => String::from_utf8_lossy(&*file_comment_raw).into_owned(), + true => String::from_utf8_lossy(&file_comment_raw).into_owned(), false => file_comment_raw.from_cp437(), }; @@ -1085,7 +1085,7 @@ pub fn read_zipfile_from_stream<'a, R: io::Read>( reader.read_exact(&mut extra_field)?; let file_name = match is_utf8 { - true => String::from_utf8_lossy(&*file_name_raw).into_owned(), + true => String::from_utf8_lossy(&file_name_raw).into_owned(), false => file_name_raw.clone().from_cp437(), }; diff --git a/src/write.rs b/src/write.rs index 61ce378c..e43cc85f 100644 --- a/src/write.rs +++ b/src/write.rs @@ -1301,7 +1301,7 @@ fn path_to_string(path: &std::path::Path) -> String { if !path_str.is_empty() { path_str.push('/'); } - path_str.push_str(&*os_str.to_string_lossy()); + path_str.push_str(&os_str.to_string_lossy()); } } path_str From e2ff935aaf9501ed01f8b88c36b95755149ffebe Mon Sep 17 00:00:00 2001 From: Wyatt Herkamp Date: Fri, 7 Oct 2022 13:20:50 -0400 Subject: [PATCH 4/9] Fixed new Clippy Warnings --- Cargo.toml | 2 +- examples/extract_lorem.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 439dca88..05b3f967 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ hmac = { version = "0.12.1", optional = true, features = ["reset"] } pbkdf2 = {version = "0.11.0", optional = true } sha1 = {version = "0.10.1", optional = true } time = { version = "0.3.7", features = ["formatting", "macros" ], optional = true } -zstd = { version = "0.11", optional = true } +zstd = { version = "0.11.2", optional = true } [target.'cfg(any(all(target_arch = "arm", target_pointer_width = "32"), target_arch = "mips", target_arch = "powerpc"))'.dependencies] crossbeam-utils = "0.8.8" diff --git a/examples/extract_lorem.rs b/examples/extract_lorem.rs index a34a04f4..4b3773a0 100644 --- a/examples/extract_lorem.rs +++ b/examples/extract_lorem.rs @@ -11,7 +11,7 @@ fn real_main() -> i32 { return 1; } let fname = std::path::Path::new(&*args[1]); - let zipfile = std::fs::File::open(&fname).unwrap(); + let zipfile = std::fs::File::open(fname).unwrap(); let mut archive = zip::ZipArchive::new(zipfile).unwrap(); From f4bbaf8434a3deeb22d00a58afb09186d0abce8d Mon Sep 17 00:00:00 2001 From: Wyatt Herkamp Date: Mon, 12 Sep 2022 10:26:39 -0400 Subject: [PATCH 5/9] hopefully a depend fix --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index a6996fc6..b32f39fd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ hmac = { version = "0.12.1", optional = true, features = ["reset"] } pbkdf2 = {version = "0.11.0", optional = true } sha1 = {version = "0.10.1", optional = true } time = { version = "0.3.7", features = ["formatting", "macros" ], optional = true } -zstd = { version = "0.11.0", optional = true } +zstd = { version = "0.11", optional = true } [target.'cfg(any(all(target_arch = "arm", target_pointer_width = "32"), target_arch = "mips", target_arch = "powerpc"))'.dependencies] crossbeam-utils = "0.8.8" From 24caeaac271fa93516501d5e42191f55ce21bf9b Mon Sep 17 00:00:00 2001 From: Wyatt Herkamp Date: Mon, 12 Sep 2022 18:53:15 -0400 Subject: [PATCH 6/9] Make github ci use 1.59 for time depend and fix two clippy warnings --- src/types.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/types.rs b/src/types.rs index b65fad40..9b3b00c4 100644 --- a/src/types.rs +++ b/src/types.rs @@ -44,7 +44,7 @@ mod atomic { #[cfg(feature = "time")] use time::{error::ComponentRange, Date, Month, OffsetDateTime, PrimitiveDateTime, Time}; -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum System { Dos = 0, Unix = 3, @@ -143,10 +143,8 @@ impl DateTime { second: u8, ) -> Result { if (1980..=2107).contains(&year) - && month >= 1 - && month <= 12 - && day >= 1 - && day <= 31 + && (1..=12).contains(&month) + && (1..=31).contains(&day) && hour <= 23 && minute <= 59 && second <= 60 From d59adf0990817bf6b54ed85c7abb00938b9c988d Mon Sep 17 00:00:00 2001 From: Wyatt Herkamp Date: Tue, 27 Sep 2022 13:30:55 -0400 Subject: [PATCH 7/9] Fixed new Clippy Warnings --- src/write.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/write.rs b/src/write.rs index 61ce378c..e43cc85f 100644 --- a/src/write.rs +++ b/src/write.rs @@ -1301,7 +1301,7 @@ fn path_to_string(path: &std::path::Path) -> String { if !path_str.is_empty() { path_str.push('/'); } - path_str.push_str(&*os_str.to_string_lossy()); + path_str.push_str(&os_str.to_string_lossy()); } } path_str From 2b9efe97ba10dcc88f99fdfefd1d5ae302b6a7a3 Mon Sep 17 00:00:00 2001 From: Wyatt Herkamp Date: Fri, 7 Oct 2022 13:20:50 -0400 Subject: [PATCH 8/9] Fixed new Clippy Warnings --- Cargo.toml | 2 +- examples/extract_lorem.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b32f39fd..fdeb9e76 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ hmac = { version = "0.12.1", optional = true, features = ["reset"] } pbkdf2 = {version = "0.11.0", optional = true } sha1 = {version = "0.10.1", optional = true } time = { version = "0.3.7", features = ["formatting", "macros" ], optional = true } -zstd = { version = "0.11", optional = true } +zstd = { version = "0.11.2", optional = true } [target.'cfg(any(all(target_arch = "arm", target_pointer_width = "32"), target_arch = "mips", target_arch = "powerpc"))'.dependencies] crossbeam-utils = "0.8.8" diff --git a/examples/extract_lorem.rs b/examples/extract_lorem.rs index a34a04f4..4b3773a0 100644 --- a/examples/extract_lorem.rs +++ b/examples/extract_lorem.rs @@ -11,7 +11,7 @@ fn real_main() -> i32 { return 1; } let fname = std::path::Path::new(&*args[1]); - let zipfile = std::fs::File::open(&fname).unwrap(); + let zipfile = std::fs::File::open(fname).unwrap(); let mut archive = zip::ZipArchive::new(zipfile).unwrap(); From 1c5cd4ffdadf0b718f86e21e55fe45725695f37a Mon Sep 17 00:00:00 2001 From: Wyatt Herkamp Date: Thu, 13 Oct 2022 07:51:02 -0400 Subject: [PATCH 9/9] Fixed new Clippy Warnings --- examples/extract.rs | 2 +- examples/file_info.rs | 2 +- examples/write_dir.rs | 2 +- examples/write_sample.rs | 2 +- src/read.rs | 10 +++++----- src/spec.rs | 4 ++-- src/types.rs | 10 +++++----- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/examples/extract.rs b/examples/extract.rs index 7b8860ca..3519ebaf 100644 --- a/examples/extract.rs +++ b/examples/extract.rs @@ -42,7 +42,7 @@ fn real_main() -> i32 { ); if let Some(p) = outpath.parent() { if !p.exists() { - fs::create_dir_all(&p).unwrap(); + fs::create_dir_all(p).unwrap(); } } let mut outfile = fs::File::create(&outpath).unwrap(); diff --git a/examples/file_info.rs b/examples/file_info.rs index 64969b66..0513c3a3 100644 --- a/examples/file_info.rs +++ b/examples/file_info.rs @@ -12,7 +12,7 @@ fn real_main() -> i32 { return 1; } let fname = std::path::Path::new(&*args[1]); - let file = fs::File::open(&fname).unwrap(); + let file = fs::File::open(fname).unwrap(); let reader = BufReader::new(file); let mut archive = zip::ZipArchive::new(reader).unwrap(); diff --git a/examples/write_dir.rs b/examples/write_dir.rs index 8cc561ff..20e599c1 100644 --- a/examples/write_dir.rs +++ b/examples/write_dir.rs @@ -114,7 +114,7 @@ fn doit( } let path = Path::new(dst_file); - let file = File::create(&path).unwrap(); + let file = File::create(path).unwrap(); let walkdir = WalkDir::new(src_dir); let it = walkdir.into_iter(); diff --git a/examples/write_sample.rs b/examples/write_sample.rs index b5749509..97a5515b 100644 --- a/examples/write_sample.rs +++ b/examples/write_sample.rs @@ -23,7 +23,7 @@ fn real_main() -> i32 { fn doit(filename: &str) -> zip::result::ZipResult<()> { let path = std::path::Path::new(filename); - let file = std::fs::File::create(&path).unwrap(); + let file = std::fs::File::create(path).unwrap(); let mut zip = zip::ZipWriter::new(file); diff --git a/src/read.rs b/src/read.rs index 0addf416..746c67b0 100644 --- a/src/read.rs +++ b/src/read.rs @@ -459,7 +459,7 @@ impl ZipArchive { fs::create_dir_all(&outpath)?; } else { if let Some(p) = outpath.parent() { - fs::create_dir_all(&p)?; + fs::create_dir_all(p)?; } let mut outfile = fs::File::create(&outpath)?; io::copy(file, &mut outfile)?; @@ -686,11 +686,11 @@ pub(crate) fn central_header_to_zip_file( reader.read_exact(&mut file_comment_raw)?; let file_name = match is_utf8 { - true => String::from_utf8_lossy(&*file_name_raw).into_owned(), + true => String::from_utf8_lossy(&file_name_raw).into_owned(), false => file_name_raw.clone().from_cp437(), }; let file_comment = match is_utf8 { - true => String::from_utf8_lossy(&*file_comment_raw).into_owned(), + true => String::from_utf8_lossy(&file_comment_raw).into_owned(), false => file_comment_raw.from_cp437(), }; @@ -1090,7 +1090,7 @@ pub fn read_zipfile_from_stream<'a, R: io::Read>( reader.read_exact(&mut extra_field)?; let file_name = match is_utf8 { - true => String::from_utf8_lossy(&*file_name_raw).into_owned(), + true => String::from_utf8_lossy(&file_name_raw).into_owned(), false => file_name_raw.clone().from_cp437(), }; @@ -1134,7 +1134,7 @@ pub fn read_zipfile_from_stream<'a, R: io::Read>( return unsupported_zip_error("The file length is not available in the local header"); } - let limit_reader = (reader as &'a mut dyn io::Read).take(result.compressed_size as u64); + let limit_reader = (reader as &'a mut dyn io::Read).take(result.compressed_size); let result_crc32 = result.crc32; let result_compression_method = result.compression_method; diff --git a/src/spec.rs b/src/spec.rs index 3ffcf732..2ed051b1 100644 --- a/src/spec.rs +++ b/src/spec.rs @@ -64,12 +64,12 @@ impl CentralDirectoryEnd { let mut pos = file_length - HEADER_SIZE; while pos >= search_upper_bound { - reader.seek(io::SeekFrom::Start(pos as u64))?; + reader.seek(io::SeekFrom::Start(pos))?; if reader.read_u32::()? == CENTRAL_DIRECTORY_END_SIGNATURE { reader.seek(io::SeekFrom::Current( BYTES_BETWEEN_MAGIC_AND_COMMENT_SIZE as i64, ))?; - let cde_start_pos = reader.seek(io::SeekFrom::Start(pos as u64))?; + let cde_start_pos = reader.seek(io::SeekFrom::Start(pos))?; return CentralDirectoryEnd::parse(reader).map(|cde| (cde, cde_start_pos)); } pos = match pos.checked_sub(1) { diff --git a/src/types.rs b/src/types.rs index 9b3b00c4..da4a42e3 100644 --- a/src/types.rs +++ b/src/types.rs @@ -115,7 +115,7 @@ impl DateTime { let years = (datepart & 0b1111111000000000) >> 9; DateTime { - year: (years + 1980) as u16, + year: years + 1980, month: months as u8, day: days as u8, hour: hours as u8, @@ -172,10 +172,10 @@ impl DateTime { Ok(DateTime { year: (dt.year()) as u16, month: (dt.month()) as u8, - day: dt.day() as u8, - hour: dt.hour() as u8, - minute: dt.minute() as u8, - second: dt.second() as u8, + day: dt.day(), + hour: dt.hour(), + minute: dt.minute(), + second: dt.second(), }) } else { Err(())