fix: option OPTION_ONE_WAY_FILE_TRANSFER (#9387)

Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
fufesou 2024-09-18 18:22:12 +08:00 committed by GitHub
parent e20f5dd001
commit e5ec6957fe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 5 deletions

View File

@ -132,7 +132,7 @@ impl ClipboardFile {
) )
} }
pub fn is_stopping_allowed_from_peer(&self) -> bool { pub fn is_beginning_message(&self) -> bool {
matches!( matches!(
self, self,
ClipboardFile::MonitorReady | ClipboardFile::FormatList { .. } ClipboardFile::MonitorReady | ClipboardFile::FormatList { .. }

View File

@ -1895,7 +1895,7 @@ impl<T: InvokeUiSession> Remote<T> {
return; 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 file_transfer_enabled = self.handler.lc.read().unwrap().enable_file_copy_paste.v;
let stop = is_stopping_allowed && !file_transfer_enabled; let stop = is_stopping_allowed && !file_transfer_enabled;
log::debug!( log::debug!(

View File

@ -440,7 +440,7 @@ impl<T: InvokeUiCM> IpcTaskRunner<T> {
Data::ClipboardFile(_clip) => { Data::ClipboardFile(_clip) => {
#[cfg(any(target_os = "windows", target_os="linux", target_os = "macos"))] #[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 is_clipboard_enabled = ContextSend::is_enabled();
let file_transfer_enabled = self.file_transfer_enabled; let file_transfer_enabled = self.file_transfer_enabled;
let stop = !is_stopping_allowed && !(is_clipboard_enabled && file_transfer_enabled); let stop = !is_stopping_allowed && !(is_clipboard_enabled && file_transfer_enabled);
@ -565,10 +565,15 @@ impl<T: InvokeUiCM> IpcTaskRunner<T> {
log::debug!( log::debug!(
"Process clipboard message from clip, stop: {}, is_stopping_allowed: {}, is_clipboard_enabled: {}, file_transfer_enabled: {}, file_transfer_enabled_peer: {}", "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); 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(); ContextSend::set_is_stopped();
} else { } 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)));
}
} }
} }
} }