bigfix #5

Merged
wikano merged 4 commits from bigfix into master 2026-01-25 02:46:53 +00:00
4 changed files with 91 additions and 79 deletions
Showing only changes of commit 79f523be48 - Show all commits

View File

@@ -262,6 +262,7 @@ impl eframe::App for P2PClientApp {
if let Some(addr) = &self.active_peer { if let Some(addr) = &self.active_peer {
if let Some(roottree) = self.loaded_fs.get(addr) { if let Some(roottree) = self.loaded_fs.get(addr) {
if let Some(root) = roottree.data.get(&hash) { if let Some(root) = roottree.data.get(&hash) {
self.current_downloading_file_map.root = hash;
self.root_downloading_file = name; self.root_downloading_file = name;
let _ = self let _ = self
.current_downloading_file_map .current_downloading_file_map
@@ -299,11 +300,12 @@ impl eframe::App for P2PClientApp {
} }
_ => {} _ => {}
} }
println!("remaining chunks size: {}", self.remaining_chunks.len());
if self.remaining_chunks.is_empty() { if self.remaining_chunks.is_empty() {
/*let file = OpenOptions::new() let file = OpenOptions::new().append(true).create(true).open(
.append(true) "./Download/".to_string()
.create(true) + &remove_null_bytes(&self.root_downloading_file.clone()),
.open(self.root_downloading_file.clone()); );
if let Some(current) = self if let Some(current) = self
.current_downloading_file_map .current_downloading_file_map
@@ -322,8 +324,10 @@ impl eframe::App for P2PClientApp {
eprintln!("error creaation file: {}", e); eprintln!("error creaation file: {}", e);
} }
} }
}*/ } else {
println!("bigfile téléchargé"); eprintln!("error root absent");
}
println!("bigfile téléchargé {}", self.root_downloading_file);
} }
} }
NetworkEvent::Success(msg, peer_username) => { NetworkEvent::Success(msg, peer_username) => {

View File

@@ -14,6 +14,10 @@ pub fn parse_received_datum(
let value = &recevied_datum[32..recevied_datum.len()]; let value = &recevied_datum[32..recevied_datum.len()];
let value_slice = value.to_vec(); let value_slice = value.to_vec();
println!("valueslice: {:?}, {}", value_slice, value_slice.len()); println!("valueslice: {:?}, {}", value_slice, value_slice.len());
let digest = Sha256::digest(&value);
if digest.to_vec() != hash_name.to_vec() {
None
} else {
let datum_type = value_slice[0]; let datum_type = value_slice[0];
match datum_type { match datum_type {
CHUNK => Some(( CHUNK => Some((
@@ -91,4 +95,5 @@ pub fn parse_received_datum(
} }
_ => None, _ => None,
} }
}
} }

View File

@@ -468,7 +468,6 @@ pub fn parse_message(
} }
} }
EventType::DatumRequestBig => { EventType::DatumRequestBig => {
let _ = &guard.remove_entry(&id);
println!("message {} retiré de la liste", id); println!("message {} retiré de la liste", id);
let received_length = u16::from_be_bytes( let received_length = u16::from_be_bytes(
received_message[TYPE..LENGTH] received_message[TYPE..LENGTH]
@@ -481,6 +480,7 @@ pub fn parse_message(
parse_received_datum(received_datum.to_vec(), received_length as usize); parse_received_datum(received_datum.to_vec(), received_length as usize);
match parsed_node { match parsed_node {
Some(tuple) => { Some(tuple) => {
let _ = &guard.remove_entry(&id);
let _ = cmd_tx.send(NetworkEvent::DataReceived( let _ = cmd_tx.send(NetworkEvent::DataReceived(
tuple.0, tuple.0,
tuple.1, tuple.1,
@@ -488,7 +488,9 @@ pub fn parse_message(
)); ));
println!("datareceived event sent"); println!("datareceived event sent");
} }
None => {} None => {
println!("message corrompu, nouvelle tentative");
}
} }
} }
_ => {} _ => {}

View File

@@ -234,7 +234,8 @@ pub fn start_retry_thread(
); );
let base: u64 = 2; let base: u64 = 2;
let backoff = base.saturating_pow(attempt as u32); // 2^1 == 2 seconds // let backoff = base.saturating_pow(attempt as u32); // 2^1 == 2 seconds
let backoff = 1;
let newretry = RetryMessage { let newretry = RetryMessage {
next_try: SystemTime::now() next_try: SystemTime::now()
.duration_since(UNIX_EPOCH) .duration_since(UNIX_EPOCH)