fix(windows): continue removal after configuration sync errors (#16865)

* fix(windows): continue removal after configuration sync errors

Signed-off-by: fufesou <linlong1266@gmail.com>

* fix(windows): revoke local trust after removal sync errors

Signed-off-by: fufesou <linlong1266@gmail.com>

---------

Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
fufesou authored and GitHub committed 2026-11-08 22:28:28 +08:00
1 parent 1ff458bdf3
commit 3c69194ac4
1 file changed
+20 -5
+20 -5
View File
@@ -1914,10 +1914,21 @@ fn get_uninstall(kill_self: bool, uninstall_printer: bool) -> ResultType<String>
pub fn uninstall_me(kill_self: bool) -> ResultType<()> {
if is_self_service_running() {
// This CLI entry is synchronous. Portable builds reuse the retained user configuration.
tokio::runtime::Builder::new_current_thread()
let result = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()?
.block_on(crate::trusted_devices::config::refresh_from_server())?;
.build()
.map_err(hbb_common::anyhow::Error::from)
.and_then(|runtime| {
runtime.block_on(crate::trusted_devices::config::refresh_from_server())
});
if let Err(error) = result {
log::warn!(
"Failed to synchronize configuration before uninstall; revoking local trusted devices before continuing: {error:#}"
);
if let Err(error) = crate::trusted_devices::clear() {
log::warn!("Failed to revoke local trust; continuing removal: {error:#}");
}
}
}
run_cmds(get_uninstall(kill_self, true)?, true, "uninstall")
}
@@ -3355,8 +3366,12 @@ pub fn uninstall_service(show_new_window: bool, _: bool) -> bool {
runtime.block_on(crate::trusted_devices::config::refresh_from_server())
});
if let Err(error) = result {
log::error!("Cannot stop service before synchronizing its configuration: {error}");
return true;
log::warn!(
"Failed to synchronize configuration before service removal; revoking local trusted devices before continuing: {error:#}"
);
if let Err(error) = crate::trusted_devices::clear() {
log::warn!("Failed to revoke local trust; continuing removal: {error:#}");
}
}
}
let filter = format!(" /FI \"PID ne {}\"", get_current_pid());