From feb31d48c14dfd0d5e2d25caa881929a473e7acd Mon Sep 17 00:00:00 2001 From: Esdras Renan Date: Tue, 11 Nov 2025 14:57:39 -0300 Subject: [PATCH] Sincroniza remote_id com ID final --- apps/desktop/src-tauri/src/rustdesk.rs | 28 ++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/apps/desktop/src-tauri/src/rustdesk.rs b/apps/desktop/src-tauri/src/rustdesk.rs index 6d535fb..59f44c6 100644 --- a/apps/desktop/src-tauri/src/rustdesk.rs +++ b/apps/desktop/src-tauri/src/rustdesk.rs @@ -103,6 +103,12 @@ pub fn provision(machine_id: &str) -> Result aplicando {reported_id}" + )); + } + ensure_remote_id_files(&reported_id); let version = query_version(&exe_path).ok().or(installed_version); @@ -207,7 +213,12 @@ fn write_file(path: &Path, contents: &str) -> Result<(), io::Error> { if let Some(parent) = path.parent() { fs::create_dir_all(parent)?; } - fs::write(path, contents) + let mut file = OpenOptions::new() + .create(true) + .write(true) + .truncate(true) + .open(path)?; + file.write_all(contents.as_bytes()) } fn program_data_config_dir() -> PathBuf { @@ -262,7 +273,6 @@ fn set_password(exe_path: &Path) -> Result<(), RustdeskError> { fn set_custom_id(exe_path: &Path, machine_id: &str) -> Result { let custom_id = derive_numeric_id(machine_id); run_with_args(exe_path, &["--set-id", &custom_id])?; - ensure_remote_id_files(&custom_id); Ok(custom_id) } @@ -376,9 +386,19 @@ fn write_remote_id_value(path: &Path, id: &str) -> io::Result<()> { if !replaced { buffer.push_str(&replacement); } - fs::write(path, buffer) + let mut file = OpenOptions::new() + .create(true) + .write(true) + .truncate(true) + .open(path)?; + file.write_all(buffer.as_bytes()) } else { - fs::write(path, replacement) + let mut file = OpenOptions::new() + .create(true) + .write(true) + .truncate(true) + .open(path)?; + file.write_all(replacement.as_bytes()) } }