diff --git a/src/patch/mod.rs b/src/patch/mod.rs index ca4c5d6..323a777 100644 --- a/src/patch/mod.rs +++ b/src/patch/mod.rs @@ -1 +1,2 @@ -pub mod patch; \ No newline at end of file +#[allow(clippy::module_inception)] +pub mod patch; diff --git a/src/patch/patch.rs b/src/patch/patch.rs index 9d71f10..13a9928 100644 --- a/src/patch/patch.rs +++ b/src/patch/patch.rs @@ -2,7 +2,7 @@ use std::collections::{HashMap, HashSet}; use std::fs; use std::io; use std::io::{Read}; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use rand::Rng; use crc::{crc32, Hasher32}; use libpso::{PacketParseError, PSOPacket}; @@ -60,7 +60,7 @@ impl PatchFileTree { PatchFileTree::Directory(dir, files) => { v.push(PatchTreeIterItem::Directory(dir.clone())); for file in files { - v.append(&mut PatchFileTree::iter_dir(&file)); + v.append(&mut PatchFileTree::iter_dir(file)); } v.push(PatchTreeIterItem::UpDirectory); }, @@ -197,7 +197,7 @@ impl ServerState for PatchServerState { let p = vec![SendPatchPacket::FilesToPatchMetadata(FilesToPatchMetadata::new(total_size, total_files)), SendPatchPacket::PatchStartList(PatchStartList {}) ]; - Box::new(p.into_iter().chain(SendFileIterator::new(&self)).map(move |pkt| (id, pkt))) + Box::new(p.into_iter().chain(SendFileIterator::new(self)).map(move |pkt| (id, pkt))) } }) } @@ -214,12 +214,11 @@ fn load_patch_dir(basedir: &str, patchbase: &str, file_ids: &mut HashMap Vec Result<(u32, u32), PatchError> { +fn get_checksum_and_size(path: &Path) -> Result<(u32, u32), PatchError> { let file = fs::File::open(path)?; let size = file.metadata().unwrap().len(); let mut crc = crc32::Digest::new(crc32::IEEE); @@ -307,7 +306,7 @@ impl SendFileIterator { file_iter: Box::new(state.patch_file_tree.flatten().into_iter().filter(move |file| { match file { PatchTreeIterItem::File(_path, id) => { - file_ids_to_update.contains(&id) + file_ids_to_update.contains(id) }, _ => true, }