@@ -38,7 +38,7 @@ func PlatformUpgrade(ctx context.Context, req *rpc.PlatformUpgradeRequest,
38
38
Package : req .PlatformPackage ,
39
39
PlatformArchitecture : req .Architecture ,
40
40
}
41
- if err := upgradePlatform ( pm , ref , downloadCB , taskCB , req .GetSkipPostInstall ()); err != nil {
41
+ if err := pm . DownloadAndInstallPlatformUpgrades ( ref , downloadCB , taskCB , req .GetSkipPostInstall ()); err != nil {
42
42
return nil , err
43
43
}
44
44
@@ -48,35 +48,3 @@ func PlatformUpgrade(ctx context.Context, req *rpc.PlatformUpgradeRequest,
48
48
49
49
return & rpc.PlatformUpgradeResponse {}, nil
50
50
}
51
-
52
- func upgradePlatform (pm * packagemanager.PackageManager , platformRef * packagemanager.PlatformReference ,
53
- downloadCB rpc.DownloadProgressCB , taskCB rpc.TaskProgressCB , skipPostInstall bool ) error {
54
- if platformRef .PlatformVersion != nil {
55
- return & arduino.InvalidArgumentError {Message : tr ("Upgrade doesn't accept parameters with version" )}
56
- }
57
-
58
- // Search the latest version for all specified platforms
59
- platform := pm .FindPlatform (platformRef )
60
- if platform == nil {
61
- return & arduino.PlatformNotFoundError {Platform : platformRef .String ()}
62
- }
63
- installed := pm .GetInstalledPlatformRelease (platform )
64
- if installed == nil {
65
- return & arduino.PlatformNotFoundError {Platform : platformRef .String ()}
66
- }
67
- latest := platform .GetLatestRelease ()
68
- if ! latest .Version .GreaterThan (installed .Version ) {
69
- return & arduino.PlatformAlreadyAtTheLatestVersionError {}
70
- }
71
- platformRef .PlatformVersion = latest .Version
72
-
73
- platformRelease , tools , err := pm .FindPlatformReleaseDependencies (platformRef )
74
- if err != nil {
75
- return & arduino.PlatformNotFoundError {Platform : platformRef .String ()}
76
- }
77
- if err := pm .DownloadAndInstallPlatformAndTools (platformRelease , tools , downloadCB , taskCB , skipPostInstall ); err != nil {
78
- return err
79
- }
80
-
81
- return nil
82
- }
0 commit comments