From 54a526f8c91be7ff98d12f838136e6cdfc0e5907 Mon Sep 17 00:00:00 2001 From: andy Date: Sat, 19 Feb 2022 23:01:24 +0000 Subject: [PATCH] remove comments and debug lines --- src/patch/patch.rs | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/src/patch/patch.rs b/src/patch/patch.rs index 4a43477..02c90f4 100644 --- a/src/patch/patch.rs +++ b/src/patch/patch.rs @@ -187,31 +187,21 @@ impl ServerState for PatchServerState { }, RecvPatchPacket::FileInfoReply(pkt) => { self.client_file_info.get_mut(&id).ok_or(PatchError::NoSuchClient(id))?.push(pkt.clone()); // it should be impossible to error here under normal conditions? - // self.patch_file_info.push(pkt.clone()); - // println!("PatchServerState.patch_file_info: {:?}", self.patch_file_info); Box::new(None.into_iter().map(move |pkt| (id, pkt))) }, RecvPatchPacket::FileInfoListEnd(_pkt) => { - // let need_update = self.patch_file_info.iter() - // .filter(|file_info| does_file_need_updating(file_info, &self.patch_file_lookup)) - // .collect::>(); - println!("patch server hashmap: {:?}", self.patch_file_lookup); let need_update = self.client_file_info.get(&id) .ok_or(PatchError::NoSuchClient(id))? .iter() .filter(|client_file_info| does_file_need_updating(client_file_info, &self.patch_file_lookup)) - .collect::>(); // collecting list of `client_file_info`s. need to map these to the patch_files and collect those - println!("ClientId({}) needs these files to be updated: {:?}", id, need_update); - // we have the file ids that need to be updated + .collect::>(); let total_size = need_update.iter() .filter_map(|client_file| self.patch_file_lookup.get(&client_file.id)) // TODO: dont unwrap? .fold(0, |a, file_info| a + file_info.size); let total_files = need_update.len() as u32; - println!("client {} needs {} bytes of updates across {} files", id, total_size, total_files); let p = vec![SendPatchPacket::FilesToPatchMetadata(FilesToPatchMetadata::new(total_size, total_files)), SendPatchPacket::PatchStartList(PatchStartList {}) ]; - println!("p: {:?}", p); Box::new(p.into_iter().chain(SendFileIterator::new(self, need_update)).map(move |pkt| (id, pkt))) } }) @@ -297,7 +287,6 @@ fn get_checksum_and_size(path: &Path) -> Result<(u32, u32), PatchError> { fn does_file_need_updating(client_file_info: &FileInfoReply, patch_file_lookup: &HashMap) -> bool { let patch_file = patch_file_lookup.get(&client_file_info.id).unwrap(); - println!("checking if client_file {:?} and patch_file {:?} need to be updated", client_file_info, patch_file); patch_file.checksum != client_file_info.checksum || patch_file.size != client_file_info.size } @@ -312,11 +301,6 @@ struct SendFileIterator { impl SendFileIterator { fn new(state: &PatchServerState, client_file_info: Vec<&FileInfoReply>) -> SendFileIterator { - // let file_ids_to_update = state.patch_file_info.iter() - // .filter(|file_info| does_file_need_updating(file_info, &state.patch_file_lookup)) - // .map(|k| k.id) - // .collect::>(); - let file_ids_to_update = client_file_info.iter() .map(|k| k.id) .collect::>();