Merge pull request #566 from Kingtous/fix/download_from_windows_cause_subfolder_collepsed

fix: Unix <-> Windows sub-folder collapsed
This commit is contained in:
RustDesk 2022-05-20 11:33:13 +08:00 committed by GitHub
commit 9987c24d91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 5 deletions

View File

@ -767,6 +767,13 @@ pub fn create_dir(dir: &str) -> ResultType<()> {
Ok(())
}
#[inline]
pub fn transform_windows_path(entries: &mut Vec<FileEntry>) {
for entry in entries {
entry.name = entry.name.replace("\\", "/");
}
}
pub enum DigestCheckResult {
IsSame,
NeedConfirm(FileTransferDigest),

View File

@ -4,9 +4,8 @@ use hbb_common::{
allow_err,
compress::decompress,
config::{Config, LocalConfig},
fs,
fs::{can_enable_overwrite_detection, get_string, new_send_confirm, DigestCheckResult},
get_version_number, log,
fs, log,
fs::{can_enable_overwrite_detection, new_send_confirm, DigestCheckResult, get_string, transform_windows_path},
message_proto::*,
protobuf::Message as _,
rendezvous_proto::ConnType,
@ -662,7 +661,10 @@ impl Connection {
}
Some(message::Union::file_response(fr)) => match fr.union {
Some(file_response::Union::dir(fd)) => {
let entries = fd.entries.to_vec();
let mut entries = fd.entries.to_vec();
if self.session.peer_platform() == "Windows" {
fs::transform_windows_path(&mut entries);
}
let id = fd.id;
self.session.push_event(
"file_dir",

View File

@ -1644,7 +1644,15 @@ impl Remote {
);
let m = make_fd(job.id(), job.files(), true);
self.handler.call("updateFolderFiles", &make_args!(m));
#[cfg(not(windows))]
let files = job.files().clone();
#[cfg(windows)]
let mut files = job.files().clone();
#[cfg(windows)]
if self.handler.peer_platform() != "Windows" {
// peer is not windows, need transform \ to /
fs::transform_windows_path(&mut files);
}
self.read_jobs.push(job);
self.timer = time::interval(MILLI1);
allow_err!(peer.send(&fs::new_receive(id, to, file_num, files)).await);
@ -2019,7 +2027,13 @@ impl Remote {
Some(message::Union::file_response(fr)) => {
match fr.union {
Some(file_response::Union::dir(fd)) => {
let entries = fd.entries.to_vec();
let mut entries = fd.entries.to_vec();
#[cfg(not(windows))]
{
if self.handler.peer_platform() == "Windows" {
fs::transform_windows_path(&mut entries);
}
}
let mut m = make_fd(fd.id, &entries, fd.id > 0);
if fd.id <= 0 {
m.set_item("path", fd.path);