@@ -38,7 +38,7 @@ func PlatformUpgrade(ctx context.Context, req *rpc.PlatformUpgradeRequest,
3838 Package : req .PlatformPackage ,
3939 PlatformArchitecture : req .Architecture ,
4040 }
41- if err := upgradePlatform ( pm , ref , downloadCB , taskCB , req .GetSkipPostInstall ()); err != nil {
41+ if err := pm . DownloadAndInstallPlatformUpgrades ( ref , downloadCB , taskCB , req .GetSkipPostInstall ()); err != nil {
4242 return nil , err
4343 }
4444
@@ -48,35 +48,3 @@ func PlatformUpgrade(ctx context.Context, req *rpc.PlatformUpgradeRequest,
4848
4949 return & rpc.PlatformUpgradeResponse {}, nil
5050}
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