-
-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
feat, update, win, macos #11618
Conversation
There was a problem hiding this 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
src/hbbs_http/downloader.rs
Outdated
std::thread::spawn(move || { | ||
std::thread::sleep(dur); |
There was a problem hiding this comment.
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.
std::thread::spawn(move || { | |
std::thread::sleep(dur); | |
tokio::spawn(async move { | |
tokio::time::sleep(dur).await; |
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
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" { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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(); |
There was a problem hiding this comment.
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.
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.
There was a problem hiding this comment.
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.
b5a0c44
to
3554bfe
Compare
src/updater.rs
Outdated
if update_url.is_empty() { | ||
log::debug!("No update available."); | ||
} else { | ||
let download_url = update_url.replace("tag", "download"); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applied.
3554bfe
to
d4ed5f4
Compare
c1cb1af
to
e2376fa
Compare
Signed-off-by: fufesou <linlong1266@gmail.com>
e2376fa
to
a3ac63c
Compare
Signed-off-by: fufesou <linlong1266@gmail.com>
Signed-off-by: fufesou <linlong1266@gmail.com>
Desc
update_progress.dart
.updater.rs
. Auto update will check for update 30 seconds after startup, then every 24 hoursWindows 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()
inwindows.rs
.MacOS update
The main function is
update_me()
inmacos.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
exe_x86-64
, manually update and automatically update.exe_x86
, automatically update.x86_64
,aarch64
, manually update. Both installed and not installed.exe_x86-64
andexe_x86
.msi
.Note
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 useget_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