add: send confirm request logic

This commit is contained in:
kingtous 2022-04-26 16:33:54 +08:00 committed by Kingtous
parent b08877031f
commit 5caf28ebe6

View File

@ -6,6 +6,7 @@ use crate::common::update_clipboard;
use crate::ipc;
#[cfg(any(target_os = "android", target_os = "ios"))]
use crate::{common::MOBILE_INFO2, mobile::connection_manager::start_channel};
use hbb_common::log::debug;
use hbb_common::message_proto::file_transfer_send_confirm_request::Union;
use hbb_common::{
config::Config,
@ -1020,8 +1021,33 @@ impl Connection {
fs::remove_job(c.id, &mut self.read_jobs);
}
Some(file_action::Union::send_confirm(r)) => {
//
let job_it = self
.read_jobs
.iter_mut()
.filter(|job| job.id() == r.id)
.next();
println!("recv send confirm request");
if let Some(job) = job_it {
if job.file_num() != r.file_num {
debug!("file num truncated, ignoring");
} else {
match r.union {
Some(file_transfer_send_confirm_request::Union::skip(s)) => {
if s {
println!("skip current file");
job.skip_current_file();
} else {
job.set_file_confirmed(true);
}
}
Some(file_transfer_send_confirm_request::Union::offset_blk(offset)) => {
println!("file confirmed");
job.set_file_confirmed(true);
},
_ => {}
}
}
}
}
_ => {}
}