Skip to content

feat, update, win, macos #11618

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 3, 2025
Merged

Conversation

fufesou
Copy link
Collaborator

@fufesou fufesou commented May 1, 2025

Desc

OS Version Manually Automatically
Windows x86_64 exe
Windows msi
Windows x86 - exe
MacOS x86
MacOS aarch64
  1. Easy update when clicking "Click to update" on Windows/MacOS. The main code is in update_progress.dart.
  2. Provide an "Auto update" option on Windows. The main code is in updater.rs. Auto update will check for update 30 seconds after startup, then every 24 hours

Windows update

The update logic is stop service -> kill all instances -> update reg values -> copy files -> restore service -> restore main window and tray process.

The main function is update_me() in windows.rs.

MacOS update

The main function is update_me() in macos.rs.

Preview

exe-64-update-1.mp4

The test app does not use the official release page.

download-failed.mp4
exe-64-update-2.mp4
win-msi-update.mp4
win-sciter-auto-update.mp4
macos-update-installed.mp4
macos-update-not-installed.mp4

Tests

  • Windows, exe_x86-64, manually update and automatically update.
  • Windows msi, manually update and automatically update.
  • Windows exe_x86, automatically update.
  • MacOS, x86_64, aarch64, manually update. Both installed and not installed.
  • Automatically update when the screen is in "Logon" (Signed out and Switching user) and "Lock" window on Windows,exe_x86-64 and exe_x86.
  • Automatically update when the screen is in "Logon" (Signed out and Switching user) and "Lock" window on Windows,msi.

Note

  1. Msi auto update will not start the tray app and the main window.
  2. Crate sysinfo can't detect the process command line if is x86 builds. But we need to check --connect, ----file-transfer before updating. So we have to use get_pids_of_process_with_first_arg_by_wmic() as a workaround.

The test apps can be downloaded from https://github.com/fufesou/rustdesk/releases/tag/test-update and https://github.com/fufesou/rustdesk/releases/tag/1.4.0

@fufesou fufesou requested a review from Copilot May 1, 2025 12:14
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces update functionality for both Windows and MacOS along with new language keys for update messages, revisions to the IPC protocol, and a new HTTP downloader module.

  • Adds new translation keys for update notifications across several languages.
  • Introduces a new IPC data variant and an updater routine to support controlling session count.
  • Implements an asynchronous downloader module for file downloads and integrates it into the Flutter FFI code and core update logic.

Reviewed Changes

Copilot reviewed 65 out of 72 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/lang/*.rs Added new translation keys for update-related user notifications.
src/ipc.rs Introduced a new enum variant (ControllingSessionCount) and handler.
src/hbbs_http/downloader.rs Added a new downloader module with asynchronous downloading and auto-deletion functionality.
src/hbbs_http.rs Exported the downloader module.
src/flutter_ffi.rs Integrated downloader and update logic triggered on specific keys.
src/flutter.rs Updated session management to send updates to the server on session removal/registration.
src/core_main.rs Extended update functionality handling for Windows and MacOS.
src/common.rs Renamed the software update async function to do_check_software_update.
Files not reviewed (7)
  • flutter/lib/common.dart: Language not supported
  • flutter/lib/consts.dart: Language not supported
  • flutter/lib/desktop/pages/desktop_home_page.dart: Language not supported
  • flutter/lib/desktop/pages/desktop_setting_page.dart: Language not supported
  • flutter/lib/desktop/widgets/update_progress.dart: Language not supported
  • res/msi/Package/Components/RustDesk.wxs: Language not supported
  • res/msi/Package/Fragments/AddRemoveProperties.wxs: Language not supported

Comment on lines 230 to 231
std::thread::spawn(move || {
std::thread::sleep(dur);
Copy link
Preview

Copilot AI May 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using tokio::spawn instead of std::thread::spawn to launch the auto-deletion task so that it integrates better with the async runtime and avoids potential thread-safety issues.

Suggested change
std::thread::spawn(move || {
std::thread::sleep(dur);
tokio::spawn(async move {
tokio::time::sleep(dur).await;

Copilot uses AI. Check for mistakes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied

#[cfg(any(target_os = "windows", target_os = "macos"))]
{
use crate::updater::get_download_file_from_url;
if _key == "download-new-version" {
Copy link
Preview

Copilot AI May 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the update branch for downloading a new version removes a file unconditionally using std::fs::remove_file(...).ok(), it might be beneficial to log or handle errors there to ensure that unnoticed failures don’t lead to inconsistent state.

Copilot uses AI. Check for mistakes.

Copy link
Collaborator Author

@fufesou fufesou May 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to change.
It's ok to ignore the errors here. The new version file in downloaded in the user's temporary directory.

Comment on lines +194 to +210
return None;
}
let res = platform::update_me(false);
let text = match res {
Ok(_) => translate("Update successfully!".to_string()),
Err(err) => {
log::error!("Failed with error: {err}");
translate("Update failed!".to_string())
}
};
Toast::new(Toast::POWERSHELL_APP_ID)
.title(&config::APP_NAME.read().unwrap())
.text1(&text)
.sound(Some(Sound::Default))
.duration(Duration::Short)
.show()
.ok();
Copy link
Preview

Copilot AI May 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] In the '--update' branch, after checking config::is_disable_installation(), consider adding more robust error handling or logging around the update process to aid troubleshooting if the update fails at runtime.

Suggested change
return None;
}
let res = platform::update_me(false);
let text = match res {
Ok(_) => translate("Update successfully!".to_string()),
Err(err) => {
log::error!("Failed with error: {err}");
translate("Update failed!".to_string())
}
};
Toast::new(Toast::POWERSHELL_APP_ID)
.title(&config::APP_NAME.read().unwrap())
.text1(&text)
.sound(Some(Sound::Default))
.duration(Duration::Short)
.show()
.ok();
log::warn!("Update process skipped because installation is disabled.");
return None;
}
match platform::update_me(false) {
Ok(_) => {
let success_message = translate("Update successfully!".to_string());
log::info!("Update completed successfully.");
Toast::new(Toast::POWERSHELL_APP_ID)
.title(&config::APP_NAME.read().unwrap())
.text1(&success_message)
.sound(Some(Sound::Default))
.duration(Duration::Short)
.show()
.ok();
}
Err(err) => {
log::error!("Update failed with error: {err:?}");
let failure_message = translate("Update failed!".to_string());
Toast::new(Toast::POWERSHELL_APP_ID)
.title(&config::APP_NAME.read().unwrap())
.text1(&failure_message)
.sound(Some(Sound::Default))
.duration(Duration::Short)
.show()
.ok();
}
}

Copilot uses AI. Check for mistakes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe no need to log errors here.

@fufesou fufesou force-pushed the feat/update_win_macos branch from b5a0c44 to 3554bfe Compare May 1, 2025 12:25
src/updater.rs Outdated
if update_url.is_empty() {
log::debug!("No update available.");
} else {
let download_url = update_url.replace("tag", "download");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too many unnessary
{
{
{

here all you can use if .. return instead

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied.

@fufesou fufesou force-pushed the feat/update_win_macos branch from 3554bfe to d4ed5f4 Compare May 2, 2025 01:15
@fufesou fufesou closed this May 2, 2025
@fufesou fufesou reopened this May 2, 2025
@fufesou fufesou force-pushed the feat/update_win_macos branch 2 times, most recently from c1cb1af to e2376fa Compare May 2, 2025 01:25
Signed-off-by: fufesou <linlong1266@gmail.com>
@fufesou fufesou force-pushed the feat/update_win_macos branch from e2376fa to a3ac63c Compare May 2, 2025 15:00
@rustdesk rustdesk merged commit ca00706 into rustdesk:master May 3, 2025
19 of 21 checks passed
fufesou added a commit to fufesou/rustdesk that referenced this pull request May 4, 2025
Signed-off-by: fufesou <linlong1266@gmail.com>
fufesou added a commit to fufesou/rustdesk that referenced this pull request May 4, 2025
Signed-off-by: fufesou <linlong1266@gmail.com>
Repository owner deleted a comment from twprh May 4, 2025
Repository owner locked and limited conversation to collaborators May 4, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants