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

Unused imports and version fix #39

Merged
merged 3 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
28 changes: 14 additions & 14 deletions src/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ impl Default for Record<BufferedBody> {
fn default() -> Record<BufferedBody> {
Record {
headers: RawRecordHeader {
version: "WARC/1.0".to_string(),
version: "1.0".to_string(),
headers: HashMap::new(),
},
record_date: Utc::now(),
Expand All @@ -622,7 +622,7 @@ impl Default for Record<EmptyBody> {
fn default() -> Record<EmptyBody> {
Record {
headers: RawRecordHeader {
version: "WARC/1.0".to_string(),
version: "1.0".to_string(),
headers: HashMap::new(),
},
record_date: Utc::now(),
Expand Down Expand Up @@ -795,7 +795,7 @@ mod record_tests {
std::thread::sleep(std::time::Duration::from_millis(10));
let after = Utc::now();
assert_eq!(record.content_length(), 0);
assert_eq!(record.warc_version(), "WARC/1.0");
assert_eq!(record.warc_version(), "1.0");
assert_eq!(record.warc_type(), &RecordType::Resource);
assert!(record.date() > &before);
assert!(record.date() < &after);
Expand Down Expand Up @@ -929,7 +929,7 @@ mod raw_tests {
#[test]
fn create() {
let headers = RawRecordHeader {
version: "WARC/1.0".to_owned(),
version: "1.0".to_owned(),
headers: HashMap::new(),
};

Expand All @@ -939,7 +939,7 @@ mod raw_tests {
#[test]
fn create_with_headers() {
let headers = RawRecordHeader {
version: "WARC/1.0".to_owned(),
version: "1.0".to_owned(),
headers: vec![(
WarcHeader::WarcType,
RecordType::WarcInfo.to_string().into_bytes(),
Expand All @@ -954,7 +954,7 @@ mod raw_tests {
#[test]
fn verify_ok() {
let headers = RawRecordHeader {
version: "WARC/1.0".to_owned(),
version: "1.0".to_owned(),
headers: vec![
(WarcHeader::WarcType, b"dunno".to_vec()),
(WarcHeader::ContentLength, b"5".to_vec()),
Expand All @@ -974,7 +974,7 @@ mod raw_tests {
#[test]
fn verify_missing_type() {
let headers = RawRecordHeader {
version: "WARC/1.0".to_owned(),
version: "1.0".to_owned(),
headers: vec![
(WarcHeader::ContentLength, b"5".to_vec()),
(
Expand All @@ -993,7 +993,7 @@ mod raw_tests {
#[test]
fn verify_missing_content_length() {
let headers = RawRecordHeader {
version: "WARC/1.0".to_owned(),
version: "1.0".to_owned(),
headers: vec![
(WarcHeader::WarcType, b"dunno".to_vec()),
(
Expand All @@ -1012,7 +1012,7 @@ mod raw_tests {
#[test]
fn verify_missing_record_id() {
let headers = RawRecordHeader {
version: "WARC/1.0".to_owned(),
version: "1.0".to_owned(),
headers: vec![
(WarcHeader::WarcType, b"dunno".to_vec()),
(WarcHeader::ContentLength, b"5".to_vec()),
Expand All @@ -1028,7 +1028,7 @@ mod raw_tests {
#[test]
fn verify_missing_date() {
let headers = RawRecordHeader {
version: "WARC/1.0".to_owned(),
version: "1.0".to_owned(),
headers: vec![
(WarcHeader::WarcType, b"dunno".to_vec()),
(WarcHeader::ContentLength, b"5".to_vec()),
Expand Down Expand Up @@ -1057,7 +1057,7 @@ mod builder_tests {
#[test]
fn default() {
let (headers, body) = RecordBuilder::default().build_raw();
assert_eq!(headers.version, "WARC/1.0".to_string());
assert_eq!(headers.version, "1.0".to_string());
assert_eq!(
headers.as_ref().get(&WarcHeader::ContentLength).unwrap(),
&b"0".to_vec()
Expand All @@ -1074,7 +1074,7 @@ mod builder_tests {
let (headers, body) = RecordBuilder::default()
.body(b"abcdef".to_vec())
.build_raw();
assert_eq!(headers.version, "WARC/1.0".to_string());
assert_eq!(headers.version, "1.0".to_string());
assert_eq!(
headers.as_ref().get(&WarcHeader::ContentLength).unwrap(),
&b"6".to_vec()
Expand Down Expand Up @@ -1111,7 +1111,7 @@ mod builder_tests {
#[test]
fn create_with_headers() {
let headers = RawRecordHeader {
version: "WARC/1.0".to_owned(),
version: "1.0".to_owned(),
headers: vec![(
WarcHeader::WarcType,
RecordType::WarcInfo.to_string().into_bytes(),
Expand All @@ -1126,7 +1126,7 @@ mod builder_tests {
#[test]
fn verify_ok() {
let headers = RawRecordHeader {
version: "WARC/1.0".to_owned(),
version: "1.0".to_owned(),
headers: vec![
(WarcHeader::WarcType, b"dunno".to_vec()),
(WarcHeader::ContentLength, b"5".to_vec()),
Expand Down
4 changes: 1 addition & 3 deletions src/warc_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
.write(true)
.create(true)
.open(&path)?;
let reader = BufReader::with_capacity(1 * MB, file);

Check warning on line 60 in src/warc_reader.rs

View workflow job for this annotation

GitHub Actions / Clippy linting

this operation has no effect

Ok(WarcReader::new(reader))
}
Expand All @@ -71,7 +71,7 @@
pub fn from_path_gzip<P: AsRef<Path>>(path: P) -> io::Result<Self> {
let file = fs::File::open(&path)?;

let gzip_stream = GzipReader::new(BufReader::with_capacity(1 * MB, file))?;

Check warning on line 74 in src/warc_reader.rs

View workflow job for this annotation

GitHub Actions / Clippy linting

this operation has no effect
Ok(WarcReader::new(BufReader::new(gzip_stream)))
}
}
Expand Down Expand Up @@ -119,7 +119,7 @@
let headers_ref = headers_parsed.1;
let expected_body_len = headers_parsed.2;

let mut body_buffer: Vec<u8> = Vec::with_capacity(1 * MB);

Check warning on line 122 in src/warc_reader.rs

View workflow job for this annotation

GitHub Actions / Clippy linting

this operation has no effect
let mut found_body = expected_body_len == 0;
let mut body_bytes_read = 0;
let maximum_read_range = expected_body_len + 4;
Expand Down Expand Up @@ -202,7 +202,7 @@
let headers_ref = headers_parsed.1;
let expected_body_len = headers_parsed.2;

let mut body_buffer: Vec<u8> = Vec::with_capacity(1 * MB);

Check warning on line 205 in src/warc_reader.rs

View workflow job for this annotation

GitHub Actions / Clippy linting

this operation has no effect
let mut found_body = expected_body_len == 0;
let mut body_bytes_read = 0;
let maximum_read_range = expected_body_len + 4;
Expand Down Expand Up @@ -271,7 +271,7 @@
}

fn skip_body(&mut self) -> Result<(), Error> {
let mut read_buffer = [0u8; 1 * MB];

Check warning on line 274 in src/warc_reader.rs

View workflow job for this annotation

GitHub Actions / Clippy linting

this operation has no effect
let maximum_read_range = self.current_item_size;
let mut body_bytes_left = maximum_read_range;
while body_bytes_left > 0 {
Expand Down Expand Up @@ -484,11 +484,9 @@

#[cfg(test)]
mod next_item_tests {
use std::collections::HashMap;
use std::io::{BufReader, Cursor};
use std::iter::FromIterator;

use crate::{WarcHeader, WarcReader};
use crate::WarcReader;

macro_rules! create_reader {
($raw:expr) => {{
Expand Down
Loading