@@ -26,21 +26,20 @@ import (
26
26
27
27
// PlatformUpgradeStreamResponseToCallbackFunction returns a gRPC stream to be used in PlatformUpgrade that sends
28
28
// all responses to the callback function.
29
- func PlatformUpgradeStreamResponseToCallbackFunction (ctx context.Context , downloadCB rpc.DownloadProgressCB , taskCB rpc.TaskProgressCB ) (rpc.ArduinoCoreService_PlatformUpgradeServer , func () * rpc.Platform ) {
30
- var resp * rpc.Platform
29
+ func PlatformUpgradeStreamResponseToCallbackFunction (ctx context.Context , downloadCB rpc.DownloadProgressCB , taskCB rpc.TaskProgressCB ) (rpc.ArduinoCoreService_PlatformUpgradeServer , func () * rpc.PlatformUpgradeResponse_Result ) {
30
+ var resp * rpc.PlatformUpgradeResponse_Result
31
31
return streamResponseToCallback (ctx , func (r * rpc.PlatformUpgradeResponse ) error {
32
- // TODO: use oneof in protoc files?
33
32
if r .GetProgress () != nil {
34
33
downloadCB (r .GetProgress ())
35
34
}
36
35
if r .GetTaskProgress () != nil {
37
36
taskCB (r .GetTaskProgress ())
38
37
}
39
- if r .GetPlatform () != nil {
40
- resp = r .GetPlatform ()
38
+ if r .GetResult () != nil {
39
+ resp = r .GetResult ()
41
40
}
42
41
return nil
43
- }), func () * rpc.Platform {
42
+ }), func () * rpc.PlatformUpgradeResponse_Result {
44
43
return resp
45
44
}
46
45
}
@@ -49,8 +48,20 @@ func PlatformUpgradeStreamResponseToCallbackFunction(ctx context.Context, downlo
49
48
func (s * arduinoCoreServerImpl ) PlatformUpgrade (req * rpc.PlatformUpgradeRequest , stream rpc.ArduinoCoreService_PlatformUpgradeServer ) error {
50
49
syncSend := NewSynchronizedSend (stream .Send )
51
50
ctx := stream .Context ()
52
- downloadCB := func (p * rpc.DownloadProgress ) { syncSend .Send (& rpc.PlatformUpgradeResponse {Progress : p }) }
53
- taskCB := func (p * rpc.TaskProgress ) { syncSend .Send (& rpc.PlatformUpgradeResponse {TaskProgress : p }) }
51
+ downloadCB := func (p * rpc.DownloadProgress ) {
52
+ syncSend .Send (& rpc.PlatformUpgradeResponse {
53
+ Message : & rpc.PlatformUpgradeResponse_Progress {
54
+ Progress : p ,
55
+ },
56
+ })
57
+ }
58
+ taskCB := func (p * rpc.TaskProgress ) {
59
+ syncSend .Send (& rpc.PlatformUpgradeResponse {
60
+ Message : & rpc.PlatformUpgradeResponse_TaskProgress {
61
+ TaskProgress : p ,
62
+ },
63
+ })
64
+ }
54
65
55
66
upgrade := func () (* cores.PlatformRelease , error ) {
56
67
pme , release , err := instances .GetPackageManagerExplorer (req .GetInstance ())
@@ -75,9 +86,13 @@ func (s *arduinoCoreServerImpl) PlatformUpgrade(req *rpc.PlatformUpgradeRequest,
75
86
platformRelease , err := upgrade ()
76
87
if platformRelease != nil {
77
88
syncSend .Send (& rpc.PlatformUpgradeResponse {
78
- Platform : & rpc.Platform {
79
- Metadata : platformToRPCPlatformMetadata (platformRelease .Platform ),
80
- Release : platformReleaseToRPC (platformRelease ),
89
+ Message : & rpc.PlatformUpgradeResponse_Result_ {
90
+ Result : & rpc.PlatformUpgradeResponse_Result {
91
+ Platform : & rpc.Platform {
92
+ Metadata : platformToRPCPlatformMetadata (platformRelease .Platform ),
93
+ Release : platformReleaseToRPC (platformRelease ),
94
+ },
95
+ },
81
96
},
82
97
})
83
98
}
0 commit comments