mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
feat: add skip feature
This commit is contained in:
@@ -215,6 +215,8 @@ pub struct TransferJob {
|
||||
transferred: u64,
|
||||
enable_overwrite_detection: bool,
|
||||
file_confirmed: bool,
|
||||
// indicating the last file is skipped
|
||||
file_skipped: bool,
|
||||
file_is_waiting: bool,
|
||||
default_overwrite_strategy: Option<bool>,
|
||||
}
|
||||
@@ -541,25 +543,50 @@ impl TransferJob {
|
||||
pub fn set_file_confirmed(&mut self, file_confirmed: bool) {
|
||||
log::info!("id: {}, file_confirmed: {}", self.id, file_confirmed);
|
||||
self.file_confirmed = file_confirmed;
|
||||
self.file_skipped = false;
|
||||
}
|
||||
|
||||
pub fn set_file_is_waiting(&mut self, file_is_waiting: bool) {
|
||||
self.file_is_waiting = file_is_waiting;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn file_is_waiting(&self) -> bool {
|
||||
self.file_is_waiting
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn file_confirmed(&self) -> bool {
|
||||
self.file_confirmed
|
||||
}
|
||||
|
||||
pub fn skip_current_file(&mut self) -> bool {
|
||||
/// Indicating whether the last file is skipped
|
||||
#[inline]
|
||||
pub fn file_skipped(&self) -> bool {
|
||||
self.file_skipped
|
||||
}
|
||||
|
||||
/// Indicating whether the whole task is skipped
|
||||
#[inline]
|
||||
pub fn job_skipped(&self) -> bool {
|
||||
self.file_skipped() && self.files.len() == 1
|
||||
}
|
||||
|
||||
/// Get job error message, useful for getting status when job had finished
|
||||
pub fn job_error(&self) -> Option<String> {
|
||||
if self.job_skipped() {
|
||||
return Some("skipped".to_string());
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
pub fn set_file_skipped(&mut self) -> bool {
|
||||
log::debug!("skip file {} in job {}", self.file_num, self.id);
|
||||
self.file.take();
|
||||
self.set_file_confirmed(false);
|
||||
self.set_file_is_waiting(false);
|
||||
self.file_num += 1;
|
||||
self.file_skipped = true;
|
||||
true
|
||||
}
|
||||
|
||||
@@ -571,7 +598,7 @@ impl TransferJob {
|
||||
Some(file_transfer_send_confirm_request::Union::Skip(s)) => {
|
||||
if s {
|
||||
log::debug!("skip file id:{}, file_num:{}", r.id, r.file_num);
|
||||
self.skip_current_file();
|
||||
self.set_file_skipped();
|
||||
} else {
|
||||
self.set_file_confirmed(true);
|
||||
}
|
||||
@@ -719,7 +746,10 @@ pub async fn handle_read_jobs(
|
||||
Ok(None) => {
|
||||
if !job.enable_overwrite_detection || (!job.file_confirmed && !job.file_is_waiting)
|
||||
{
|
||||
finished.push(job.id());
|
||||
// for getting error detail, we do not remove this job, we will handle it in io loop
|
||||
if job.job_error().is_none() {
|
||||
finished.push(job.id());
|
||||
}
|
||||
stream.send(&new_done(job.id(), job.file_num())).await?;
|
||||
} else {
|
||||
// waiting confirmation.
|
||||
|
||||
Reference in New Issue
Block a user