mirror of https://github.com/jetkvm/kvm.git
chore(ota): use []string instead of comma-separated string
This commit is contained in:
parent
0cc84f0c54
commit
005505a2da
11
ota.go
11
ota.go
|
|
@ -137,7 +137,7 @@ func rpcGetLocalVersion() (*ota.LocalMetadata, error) {
|
|||
type updateParams struct {
|
||||
AppTargetVersion string `json:"appTargetVersion"`
|
||||
SystemTargetVersion string `json:"systemTargetVersion"`
|
||||
Components string `json:"components,omitempty"` // components is a comma-separated list of components to update
|
||||
Components []string `json:"components,omitempty"`
|
||||
}
|
||||
|
||||
func rpcTryUpdate() error {
|
||||
|
|
@ -154,9 +154,7 @@ func rpcCheckUpdateComponents(params updateParams, includePreRelease bool) (*ota
|
|||
IncludePreRelease: includePreRelease,
|
||||
AppTargetVersion: params.AppTargetVersion,
|
||||
SystemTargetVersion: params.SystemTargetVersion,
|
||||
}
|
||||
if params.Components != "" {
|
||||
updateParams.Components = strings.Split(params.Components, ",")
|
||||
Components: params.Components,
|
||||
}
|
||||
info, err := otaState.GetUpdateStatus(context.Background(), updateParams)
|
||||
if err != nil {
|
||||
|
|
@ -170,6 +168,7 @@ func rpcTryUpdateComponents(params updateParams, includePreRelease bool, resetCo
|
|||
DeviceID: GetDeviceID(),
|
||||
IncludePreRelease: includePreRelease,
|
||||
ResetConfig: resetConfig,
|
||||
Components: params.Components,
|
||||
}
|
||||
|
||||
updateParams.AppTargetVersion = params.AppTargetVersion
|
||||
|
|
@ -182,10 +181,6 @@ func rpcTryUpdateComponents(params updateParams, includePreRelease bool, resetCo
|
|||
return fmt.Errorf("failed to set system target version: %w", err)
|
||||
}
|
||||
|
||||
if params.Components != "" {
|
||||
updateParams.Components = strings.Split(params.Components, ",")
|
||||
}
|
||||
|
||||
go func() {
|
||||
err := otaState.TryUpdate(context.Background(), updateParams)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ export default function SettingsAdvancedRoute() {
|
|||
// because it will be redirected to the update page later
|
||||
setVersionUpdateLoading(true);
|
||||
versionInfo = await checkUpdateComponents({
|
||||
components: components.join(","),
|
||||
components,
|
||||
appTargetVersion: appVersion,
|
||||
systemTargetVersion: systemVersion,
|
||||
}, devChannel);
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ export default function SettingsGeneralUpdateRoute() {
|
|||
|
||||
send("tryUpdateComponents", {
|
||||
params: {
|
||||
components: components.join(","),
|
||||
components,
|
||||
appTargetVersion,
|
||||
systemTargetVersion,
|
||||
},
|
||||
|
|
@ -196,13 +196,12 @@ function LoadingState({
|
|||
return await getVersionInfo();
|
||||
}
|
||||
const params : updateParams = {
|
||||
components: "",
|
||||
components: [],
|
||||
appTargetVersion: customAppVersion,
|
||||
systemTargetVersion: customSystemVersion,
|
||||
};
|
||||
if (customAppVersion) params.components += ",app";
|
||||
if (customSystemVersion) params.components += ",system";
|
||||
params.components = params.components?.replace(/^,+/, "");
|
||||
if (customAppVersion) params.components?.push("app");
|
||||
if (customSystemVersion) params.components?.push("system");
|
||||
|
||||
return await checkUpdateComponents(params, false);
|
||||
}, [customAppVersion, customSystemVersion, getVersionInfo]);
|
||||
|
|
|
|||
|
|
@ -246,7 +246,7 @@ export async function getLocalVersion() {
|
|||
export interface updateParams {
|
||||
appTargetVersion?: string;
|
||||
systemTargetVersion?: string;
|
||||
components?: string;
|
||||
components?: string[];
|
||||
}
|
||||
|
||||
export async function checkUpdateComponents(params: updateParams, includePreRelease: boolean) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue