fix: linux <- windows subfolder collepsed

This commit is contained in:
Kingtous 2022-05-20 10:51:13 +08:00
parent b267da2e70
commit c4663ecbf3
3 changed files with 20 additions and 5 deletions

View File

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

View File

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

View File

@ -2019,7 +2019,13 @@ impl Remote {
Some(message::Union::file_response(fr)) => { Some(message::Union::file_response(fr)) => {
match fr.union { match fr.union {
Some(file_response::Union::dir(fd)) => { 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); let mut m = make_fd(fd.id, &entries, fd.id > 0);
if fd.id <= 0 { if fd.id <= 0 {
m.set_item("path", fd.path); m.set_item("path", fd.path);