fix remote_dir

This commit is contained in:
rustdesk 2022-04-07 22:13:30 +08:00
parent 840413db5f
commit fa2407d857
2 changed files with 24 additions and 2 deletions

View File

@ -969,6 +969,25 @@ impl LoginConfigHandler {
self.save_config(config);
}
fn get_remote_dir(&self) -> String {
serde_json::from_str::<HashMap<String, String>>(&self.get_option("remote_dir"))
.unwrap_or_default()
.remove(&self.info.username)
.unwrap_or_default()
}
pub fn get_all_remote_dir(&self, path: String) -> String {
let d = self.get_option("remote_dir");
let user = self.info.username.clone();
let mut x = serde_json::from_str::<HashMap<String, String>>(&d).unwrap_or_default();
if path.is_empty() {
x.remove(&user);
} else {
x.insert(user, path);
}
serde_json::to_string::<HashMap<String, String>>(&x).unwrap_or_default()
}
fn create_login_msg(&self, password: Vec<u8>) -> Message {
#[cfg(any(target_os = "android", target_os = "ios"))]
let my_id = crate::common::MOBILE_INFO1.lock().unwrap().clone();
@ -984,7 +1003,7 @@ impl LoginConfigHandler {
};
if self.is_file_transfer {
lr.set_file_transfer(FileTransfer {
dir: self.get_option("remote_dir"),
dir: self.get_remote_dir(),
show_hidden: !self.get_option("remote_show_hidden").is_empty(),
..Default::default()
});

View File

@ -539,7 +539,10 @@ impl Handler {
if self.is_file_transfer() {
let close_state = self.read().unwrap().close_state.clone();
let mut has_change = false;
for (k, v) in close_state {
for (k, mut v) in close_state {
if k == "remote_dir" {
v = self.lc.read().unwrap().get_all_remote_dir(v);
}
let v2 = if v.is_empty() { None } else { Some(&v) };
if v2 != config.options.get(&k) {
has_change = true;