feat(cloud): disconnect from cloud immediately when cloud URL changes or user requests to deregister

This commit is contained in:
Siyuan Miao
2025-04-04 12:58:19 +02:00
parent f3b5011d65
commit 73e715117e
2 changed files with 49 additions and 0 deletions

View File

@@ -771,9 +771,14 @@ func rpcSetUsbDeviceState(device string, enabled bool) error {
}
func rpcSetCloudUrl(apiUrl string, appUrl string) error {
currentCloudURL := config.CloudURL
config.CloudURL = apiUrl
config.CloudAppURL = appUrl
if currentCloudURL != apiUrl {
disconnectCloud(fmt.Errorf("cloud url changed from %s to %s", currentCloudURL, apiUrl))
}
if err := SaveConfig(); err != nil {
return fmt.Errorf("failed to save config: %w", err)
}