fix: add version key to detect specific send/recv logic

This commit is contained in:
Kingtous 2022-08-01 09:50:23 +08:00
parent aabe08d657
commit 3458c164fb
7 changed files with 20 additions and 11 deletions

View File

@ -64,6 +64,7 @@ message LoginRequest {
} }
bool video_ack_required = 9; bool video_ack_required = 9;
uint64 session_id = 10; uint64 session_id = 10;
string version = 11;
} }
message ChatMessage { string text = 1; } message ChatMessage { string text = 1; }

View File

@ -276,7 +276,7 @@ impl TransferJob {
show_hidden: bool, show_hidden: bool,
is_remote: bool, is_remote: bool,
files: Vec<FileEntry>, files: Vec<FileEntry>,
enable_override_detection: bool, enable_overwrite_detection: bool,
) -> Self { ) -> Self {
log::info!("new write {}", path); log::info!("new write {}", path);
let total_size = files.iter().map(|x| x.size as u64).sum(); let total_size = files.iter().map(|x| x.size as u64).sum();
@ -289,7 +289,7 @@ impl TransferJob {
is_remote, is_remote,
files, files,
total_size, total_size,
enable_overwrite_detection: enable_override_detection, enable_overwrite_detection,
..Default::default() ..Default::default()
} }
} }
@ -301,7 +301,7 @@ impl TransferJob {
file_num: i32, file_num: i32,
show_hidden: bool, show_hidden: bool,
is_remote: bool, is_remote: bool,
enable_override_detection: bool, enable_overwrite_detection: bool,
) -> ResultType<Self> { ) -> ResultType<Self> {
log::info!("new read {}", path); log::info!("new read {}", path);
let files = get_recursive_files(&path, show_hidden)?; let files = get_recursive_files(&path, show_hidden)?;
@ -315,7 +315,7 @@ impl TransferJob {
is_remote, is_remote,
files, files,
total_size, total_size,
enable_overwrite_detection: enable_override_detection, enable_overwrite_detection,
..Default::default() ..Default::default()
}) })
} }

View File

@ -1151,6 +1151,7 @@ impl LoginConfigHandler {
my_name: crate::username(), my_name: crate::username(),
option: self.get_option_message(true).into(), option: self.get_option_message(true).into(),
session_id: self.session_id, session_id: self.session_id,
version: crate::VERSION.to_string(),
..Default::default() ..Default::default()
}; };
if self.is_file_transfer { if self.is_file_transfer {

View File

@ -57,6 +57,7 @@ pub enum FS {
id: i32, id: i32,
file_num: i32, file_num: i32,
files: Vec<(String, u64)>, files: Vec<(String, u64)>,
overwrite_detection: bool,
}, },
CancelWrite { CancelWrite {
id: i32, id: i32,

View File

@ -1377,9 +1377,8 @@ pub mod connection_manager {
id, id,
file_num, file_num,
mut files, mut files,
overwrite_detection
} => { } => {
// in mobile, can_enable_override_detection is always true
let od = true;
WRITE_JOBS.lock().unwrap().push(fs::TransferJob::new_write( WRITE_JOBS.lock().unwrap().push(fs::TransferJob::new_write(
id, id,
"".to_string(), "".to_string(),
@ -1395,7 +1394,7 @@ pub mod connection_manager {
..Default::default() ..Default::default()
}) })
.collect(), .collect(),
true, overwrite_detection
)); ));
} }
ipc::FS::CancelWrite { id } => { ipc::FS::CancelWrite { id } => {

View File

@ -1099,8 +1099,9 @@ impl Connection {
} }
Some(file_action::Union::Send(s)) => { Some(file_action::Union::Send(s)) => {
let id = s.id; let id = s.id;
let od = let od = can_enable_overwrite_detection(get_version_number(
can_enable_overwrite_detection(get_version_number(VERSION)); &self.lr.version,
));
let path = s.path.clone(); let path = s.path.clone();
match fs::TransferJob::new_read( match fs::TransferJob::new_read(
id, id,
@ -1123,6 +1124,11 @@ impl Connection {
} }
} }
Some(file_action::Union::Receive(r)) => { Some(file_action::Union::Receive(r)) => {
// note: 1.1.10 introduced identical file detection, which breaks original logic of send/recv files
// whenever got send/recv request, check peer version to ensure old version of rustdesk
let od = can_enable_overwrite_detection(get_version_number(
&self.lr.version,
));
self.send_fs(ipc::FS::NewWrite { self.send_fs(ipc::FS::NewWrite {
path: r.path, path: r.path,
id: r.id, id: r.id,
@ -1133,6 +1139,7 @@ impl Connection {
.drain(..) .drain(..)
.map(|f| (f.name, f.modified_time)) .map(|f| (f.name, f.modified_time))
.collect(), .collect(),
overwrite_detection: od,
}); });
} }
Some(file_action::Union::RemoveDir(d)) => { Some(file_action::Union::RemoveDir(d)) => {

View File

@ -160,8 +160,8 @@ impl ConnectionManager {
id, id,
file_num, file_num,
mut files, mut files,
overwrite_detection
} => { } => {
let od = can_enable_overwrite_detection(get_version_number(VERSION));
// cm has no show_hidden context // cm has no show_hidden context
// dummy remote, show_hidden, is_remote // dummy remote, show_hidden, is_remote
write_jobs.push(fs::TransferJob::new_write( write_jobs.push(fs::TransferJob::new_write(
@ -179,7 +179,7 @@ impl ConnectionManager {
..Default::default() ..Default::default()
}) })
.collect(), .collect(),
od, overwrite_detection,
)); ));
} }
ipc::FS::CancelWrite { id } => { ipc::FS::CancelWrite { id } => {