From e5ec6957fe86fe83902e6745d30b0b321b38e190 Mon Sep 17 00:00:00 2001 From: fufesou <13586388+fufesou@users.noreply.github.com> Date: Wed, 18 Sep 2024 18:22:12 +0800 Subject: [PATCH] fix: option OPTION_ONE_WAY_FILE_TRANSFER (#9387) Signed-off-by: fufesou --- libs/clipboard/src/lib.rs | 2 +- src/client/io_loop.rs | 2 +- src/ui_cm_interface.rs | 11 ++++++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/libs/clipboard/src/lib.rs b/libs/clipboard/src/lib.rs index a5da25512..30055740e 100644 --- a/libs/clipboard/src/lib.rs +++ b/libs/clipboard/src/lib.rs @@ -132,7 +132,7 @@ impl ClipboardFile { ) } - pub fn is_stopping_allowed_from_peer(&self) -> bool { + pub fn is_beginning_message(&self) -> bool { matches!( self, ClipboardFile::MonitorReady | ClipboardFile::FormatList { .. } diff --git a/src/client/io_loop.rs b/src/client/io_loop.rs index 46eb6f546..c23c967b5 100644 --- a/src/client/io_loop.rs +++ b/src/client/io_loop.rs @@ -1895,7 +1895,7 @@ impl Remote { return; }; - let is_stopping_allowed = clip.is_stopping_allowed_from_peer(); + let is_stopping_allowed = clip.is_beginning_message(); let file_transfer_enabled = self.handler.lc.read().unwrap().enable_file_copy_paste.v; let stop = is_stopping_allowed && !file_transfer_enabled; log::debug!( diff --git a/src/ui_cm_interface.rs b/src/ui_cm_interface.rs index e75683d8a..549798a51 100644 --- a/src/ui_cm_interface.rs +++ b/src/ui_cm_interface.rs @@ -440,7 +440,7 @@ impl IpcTaskRunner { Data::ClipboardFile(_clip) => { #[cfg(any(target_os = "windows", target_os="linux", target_os = "macos"))] { - let is_stopping_allowed = _clip.is_stopping_allowed_from_peer(); + let is_stopping_allowed = _clip.is_beginning_message(); let is_clipboard_enabled = ContextSend::is_enabled(); let file_transfer_enabled = self.file_transfer_enabled; let stop = !is_stopping_allowed && !(is_clipboard_enabled && file_transfer_enabled); @@ -565,10 +565,15 @@ impl IpcTaskRunner { log::debug!( "Process clipboard message from clip, stop: {}, is_stopping_allowed: {}, is_clipboard_enabled: {}, file_transfer_enabled: {}, file_transfer_enabled_peer: {}", stop, is_stopping_allowed, is_clipboard_enabled, file_transfer_enabled, file_transfer_enabled_peer); - if stop || crate::get_builtin_option(OPTION_ONE_WAY_FILE_TRANSFER) == "Y"{ + if stop { ContextSend::set_is_stopped(); } else { - allow_err!(self.tx.send(Data::ClipboardFile(_clip))); + if _clip.is_beginning_message() && crate::get_builtin_option(OPTION_ONE_WAY_FILE_TRANSFER) == "Y" { + // If one way file transfer is enabled, don't send clipboard file to client + // Don't call `ContextSend::set_is_stopped()`, because it will stop bidirectional file copy&paste. + } else { + allow_err!(self.tx.send(Data::ClipboardFile(_clip))); + } } } }