Skip to content

An open-source remote desktop application designed for self-hosting, as an alternative to TeamViewer.

patch: try fix flutter file copy

ClSlaid053723647bfb
diff --git a/libs/clipboard/src/context_send.rs b/libs/clipboard/src/context_send.rs
index e8fc33c1e..64ab85983 100644
--- a/libs/clipboard/src/context_send.rs
+++ b/libs/clipboard/src/context_send.rs
@@ -26,22 +26,19 @@ impl ContextSend {
pub fn enable(enabled: bool) {
let mut lock = CONTEXT_SEND.addr.lock().unwrap();
if enabled {
- if lock.is_none() {
- match crate::create_cliprdr_context(
- true,
- false,
- CLIPBOARD_RESPONSE_WAIT_TIMEOUT_SECS,
- ) {
- Ok(context) => {
- log::info!("clipboard context for file transfer created.");
- *lock = Some(context)
- }
- Err(err) => {
- log::error!(
- "create clipboard context for file transfer: {}",
- err.to_string()
- );
- }
+ if lock.is_some() {
+ return;
+ }
+ match crate::create_cliprdr_context(true, false, CLIPBOARD_RESPONSE_WAIT_TIMEOUT_SECS) {
+ Ok(context) => {
+ log::info!("clipboard context for file transfer created.");
+ *lock = Some(context)
+ }
+ Err(err) => {
+ log::error!(
+ "create clipboard context for file transfer: {}",
+ err.to_string()
+ );
}
}
} else if let Some(_clp) = lock.take() {
diff --git a/libs/clipboard/src/platform/mod.rs b/libs/clipboard/src/platform/mod.rs
index ec2149502..1a171eb5c 100644
--- a/libs/clipboard/src/platform/mod.rs
+++ b/libs/clipboard/src/platform/mod.rs
@@ -25,33 +25,30 @@ pub fn create_cliprdr_context(
_enable_others: bool,
response_wait_timeout_secs: u32,
) -> crate::ResultType<Box<dyn crate::CliprdrServiceContext>> {
- use hbb_common::log;
+ use std::{fs::Permissions, os::unix::prelude::PermissionsExt};
+
+ use hbb_common::{config::APP_NAME, log};
if !enable_files {
return Ok(Box::new(DummyCliprdrContext {}) as Box<_>);
}
let timeout = std::time::Duration::from_secs(response_wait_timeout_secs as u64);
- let mut tmp_path = std::env::temp_dir();
- tmp_path.push("rustdesk-cliprdr");
+
+ let app_name = APP_NAME.read().unwrap().clone();
+
+ let mnt_path = format!("/tmp/{}/{}", app_name, "cliprdr");
+
+ // this function must be called after the main IPC is up
+ std::fs::create_dir(&mnt_path).ok();
+ std::fs::set_permissions(&mnt_path, Permissions::from_mode(0o777)).ok();
log::info!("clear previously mounted cliprdr FUSE");
- if let Err(e) = std::process::Command::new("umount").arg(&tmp_path).status() {
- log::warn!("umount {:?} may fail: {:?}", tmp_path, e);
+ if let Err(e) = std::process::Command::new("umount").arg(&mnt_path).status() {
+ log::warn!("umount {:?} may fail: {:?}", mnt_path, e);
}
- let rd_mnt = if !tmp_path.exists() {
- log::info!("create mount point: {}", tmp_path.display());
- std::fs::create_dir_all(tmp_path.clone())?;
- tmp_path
- } else if !tmp_path.is_dir() {
- log::error!("{} is occupied and is not a directory", tmp_path.display());
- return Err(CliprdrError::CliprdrInit.into());
- } else {
- tmp_path
- };
-
- let linux_ctx = linux::ClipboardContext::new(timeout, rd_mnt)?;
+ let linux_ctx = linux::ClipboardContext::new(timeout, mnt_path.parse().unwrap())?;
log::debug!("start cliprdr FUSE");
linux_ctx.run().expect("failed to start cliprdr FUSE");
diff --git a/src/client/io_loop.rs b/src/client/io_loop.rs
index fd3bf1c6b..14c14451c 100644
--- a/src/client/io_loop.rs
+++ b/src/client/io_loop.rs
@@ -1073,7 +1073,6 @@ impl<T: InvokeUiSession> Remote<T> {
}
Some(login_response::Union::PeerInfo(pi)) => {
self.handler.handle_peer_info(pi);
- #[cfg(not(feature = "flutter"))]
self.check_clipboard_file_context();
if !(self.handler.is_file_transfer() || self.handler.is_port_forward()) {
#[cfg(feature = "flutter")]
@@ -1703,7 +1702,6 @@ impl<T: InvokeUiSession> Remote<T> {
true
}
- #[cfg(not(feature = "flutter"))]
fn check_clipboard_file_context(&self) {
#[cfg(any(target_os = "windows", target_os = "linux"))]
{
@@ -1716,7 +1714,7 @@ impl<T: InvokeUiSession> Remote<T> {
#[cfg(any(target_os = "windows", target_os = "linux"))]
fn handle_cliprdr_msg(&self, clip: hbb_common::message_proto::Cliprdr) {
log::debug!("handling cliprdr msg from server peer");
- #[cfg(all(feature = "flutter", not(target_os = "linux")))]
+ #[cfg(feature = "flutter")]
if let Some(hbb_common::message_proto::cliprdr::Union::FormatList(_)) = &clip.union {
if self.client_conn_id
!= clipboard::get_client_conn_id(&crate::flutter::get_cur_peer_id()).unwrap_or(0)
diff --git a/src/server/connection.rs b/src/server/connection.rs
index cc8e02e98..4a0d0b077 100644
--- a/src/server/connection.rs
+++ b/src/server/connection.rs
@@ -1791,6 +1791,7 @@ impl Connection {
{
#[cfg(any(target_os = "windows", target_os = "linux"))]
if let Some(clip) = msg_2_clip(_clip) {
+ log::debug!("got clipfile from client peer");
self.send_to_cm(ipc::Data::ClipboardFile(clip))
}
}
diff --git a/src/ui_cm_interface.rs b/src/ui_cm_interface.rs
index 80bba44b0..5baa852c3 100644
--- a/src/ui_cm_interface.rs
+++ b/src/ui_cm_interface.rs
@@ -575,6 +575,11 @@ pub async fn start_ipc<T: InvokeUiCM>(cm: ConnectionManager<T>) {
}
});
+ log::debug!(
+ "start_ipc enable context_send: {}",
+ Config::get_option("enable-file-transfer").is_empty()
+ );
+
#[cfg(any(target_os = "windows", target_os = "linux"))]
ContextSend::enable(Config::get_option("enable-file-transfer").is_empty());