@@ -31,7 +31,7 @@ import (
31
31
semver "go.bug.st/relaxed-semver"
32
32
)
33
33
34
- func PlatformDownload (ctx context.Context , req * rpc.PlatformDownloadReq , progress commands.ProgressCB ) (* rpc.PlatformDownloadResp , error ) {
34
+ func PlatformDownload (ctx context.Context , req * rpc.PlatformDownloadReq , downloadCB commands.DownloadProgressCB ) (* rpc.PlatformDownloadResp , error ) {
35
35
var version * semver.Version
36
36
if v , err := semver .Parse (req .Version ); err == nil {
37
37
version = v
@@ -53,13 +53,13 @@ func PlatformDownload(ctx context.Context, req *rpc.PlatformDownloadReq, progres
53
53
return nil , fmt .Errorf ("find platform dependencies: %s" , err )
54
54
}
55
55
56
- err = downloadPlatform (pm , platform , progress )
56
+ err = downloadPlatform (pm , platform , downloadCB )
57
57
if err != nil {
58
58
return nil , err
59
59
}
60
60
61
61
for _ , tool := range tools {
62
- err := downloadTool (pm , tool , progress )
62
+ err := downloadTool (pm , tool , downloadCB )
63
63
if err != nil {
64
64
return nil , fmt .Errorf ("downloading tool %s: %s" , tool , err )
65
65
}
@@ -68,53 +68,53 @@ func PlatformDownload(ctx context.Context, req *rpc.PlatformDownloadReq, progres
68
68
return & rpc.PlatformDownloadResp {}, nil
69
69
}
70
70
71
- func downloadPlatform (pm * packagemanager.PackageManager , platformRelease * cores.PlatformRelease , progress commands.ProgressCB ) error {
71
+ func downloadPlatform (pm * packagemanager.PackageManager , platformRelease * cores.PlatformRelease , downloadCB commands.DownloadProgressCB ) error {
72
72
// Download platform
73
73
resp , err := pm .DownloadPlatformRelease (platformRelease )
74
74
if err != nil {
75
75
return err
76
76
}
77
- return download (resp , platformRelease .String (), progress )
77
+ return download (resp , platformRelease .String (), downloadCB )
78
78
}
79
79
80
- func downloadTool (pm * packagemanager.PackageManager , tool * cores.ToolRelease , progress commands.ProgressCB ) error {
80
+ func downloadTool (pm * packagemanager.PackageManager , tool * cores.ToolRelease , downloadCB commands.DownloadProgressCB ) error {
81
81
// Check if tool has a flavor available for the current OS
82
82
if tool .GetCompatibleFlavour () == nil {
83
83
return fmt .Errorf ("tool %s not available for the current OS" , tool )
84
84
}
85
85
86
- return DownloadToolRelease (pm , tool , progress )
86
+ return DownloadToolRelease (pm , tool , downloadCB )
87
87
}
88
88
89
89
// DownloadToolRelease downloads a ToolRelease
90
- func DownloadToolRelease (pm * packagemanager.PackageManager , toolRelease * cores.ToolRelease , progress commands.ProgressCB ) error {
90
+ func DownloadToolRelease (pm * packagemanager.PackageManager , toolRelease * cores.ToolRelease , downloadCB commands.DownloadProgressCB ) error {
91
91
resp , err := pm .DownloadToolRelease (toolRelease )
92
92
if err != nil {
93
93
return err
94
94
}
95
- return download (resp , toolRelease .String (), progress )
95
+ return download (resp , toolRelease .String (), downloadCB )
96
96
}
97
97
98
- func download (d * downloader.Downloader , label string , progress commands.ProgressCB ) error {
98
+ func download (d * downloader.Downloader , label string , downloadCB commands.DownloadProgressCB ) error {
99
99
if d == nil {
100
100
// This signal means that the file is already downloaded
101
- progress (& rpc.DownloadProgress {
101
+ downloadCB (& rpc.DownloadProgress {
102
102
File : label ,
103
103
Completed : true ,
104
104
})
105
105
return nil
106
106
}
107
- progress (& rpc.DownloadProgress {
107
+ downloadCB (& rpc.DownloadProgress {
108
108
File : label ,
109
109
Url : d .URL ,
110
110
TotalSize : d .Size (),
111
111
})
112
112
d .RunAndPoll (func (downloaded int64 ) {
113
- progress (& rpc.DownloadProgress {Downloaded : downloaded })
113
+ downloadCB (& rpc.DownloadProgress {Downloaded : downloaded })
114
114
}, 250 * time .Millisecond )
115
115
if d .Error () != nil {
116
116
return d .Error ()
117
117
}
118
- progress (& rpc.DownloadProgress {Completed : true })
118
+ downloadCB (& rpc.DownloadProgress {Completed : true })
119
119
return nil
120
120
}
0 commit comments