lint src/patch/*
This commit is contained in:
parent
5d6b109cc5
commit
46f1f772f4
@ -1 +1,2 @@
|
||||
pub mod patch;
|
||||
#[allow(clippy::module_inception)]
|
||||
pub mod patch;
|
||||
|
@ -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<u32, Pa
|
||||
let mut dirs = Vec::new();
|
||||
for p in paths {
|
||||
let path = p.expect("not a real path").path();
|
||||
let patch_path = path.strip_prefix(basedir).unwrap();
|
||||
if path.is_dir() {
|
||||
let patch_path = path.strip_prefix(basedir).unwrap();
|
||||
dirs.push(load_patch_dir(path.to_str().unwrap(), patch_path.to_str().unwrap(), file_ids));
|
||||
}
|
||||
else {
|
||||
let patch_path = path.strip_prefix(basedir).unwrap();
|
||||
files.push(PatchFileTree::File(patch_path.to_path_buf(), file_ids.len() as u32));
|
||||
let (checksum, size) = get_checksum_and_size(&path).unwrap();
|
||||
file_ids.insert(file_ids.len() as u32, PatchFile {
|
||||
@ -264,7 +263,7 @@ fn get_file_list_packets(patch_file_tree: &PatchFileTree) -> Vec<SendPatchPacket
|
||||
pkts
|
||||
}
|
||||
|
||||
fn get_checksum_and_size(path: &PathBuf) -> 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,
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user