Skip to content

Commit 49d678d

Browse files
committed
Renamed ProgressCB -> DownloadProgressCB; other small makeups
1 parent 103a7c3 commit 49d678d

File tree

6 files changed

+28
-28
lines changed

6 files changed

+28
-28
lines changed

commands/compile/compile.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ import (
2424
)
2525

2626
func Compile(ctx context.Context, req *rpc.CompileReq,
27-
output io.Writer, taskCB commands.TaskProgressCB, downloadCB commands.ProgressCB) (*rpc.CompileResp, error) {
27+
outStream io.Writer,
28+
taskCB commands.TaskProgressCB, downloadCB commands.DownloadProgressCB) (*rpc.CompileResp, error) {
2829

2930
pm := commands.GetPackageManager(req)
3031
if pm == nil {
@@ -157,7 +158,7 @@ func Compile(ctx context.Context, req *rpc.CompileReq,
157158
builderCtx.BuiltInLibrariesDirs = paths.NewPathList(ideLibrariesPath)
158159
}
159160

160-
builderCtx.SetLogger(i18n.LoggerToIoWriter{Writer: output})
161+
builderCtx.SetLogger(i18n.LoggerToIoWriter{Writer: outStream})
161162
if req.GetShowProperties() {
162163
err = builder.RunParseHardwareAndDumpBuildProperties(builderCtx)
163164
} else if req.GetPreprocess() {

commands/core/download.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131
semver "go.bug.st/relaxed-semver"
3232
)
3333

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) {
3535
var version *semver.Version
3636
if v, err := semver.Parse(req.Version); err == nil {
3737
version = v
@@ -53,13 +53,13 @@ func PlatformDownload(ctx context.Context, req *rpc.PlatformDownloadReq, progres
5353
return nil, fmt.Errorf("find platform dependencies: %s", err)
5454
}
5555

56-
err = downloadPlatform(pm, platform, progress)
56+
err = downloadPlatform(pm, platform, downloadCB)
5757
if err != nil {
5858
return nil, err
5959
}
6060

6161
for _, tool := range tools {
62-
err := downloadTool(pm, tool, progress)
62+
err := downloadTool(pm, tool, downloadCB)
6363
if err != nil {
6464
return nil, fmt.Errorf("downloading tool %s: %s", tool, err)
6565
}
@@ -68,53 +68,53 @@ func PlatformDownload(ctx context.Context, req *rpc.PlatformDownloadReq, progres
6868
return &rpc.PlatformDownloadResp{}, nil
6969
}
7070

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 {
7272
// Download platform
7373
resp, err := pm.DownloadPlatformRelease(platformRelease)
7474
if err != nil {
7575
return err
7676
}
77-
return download(resp, platformRelease.String(), progress)
77+
return download(resp, platformRelease.String(), downloadCB)
7878
}
7979

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 {
8181
// Check if tool has a flavor available for the current OS
8282
if tool.GetCompatibleFlavour() == nil {
8383
return fmt.Errorf("tool %s not available for the current OS", tool)
8484
}
8585

86-
return DownloadToolRelease(pm, tool, progress)
86+
return DownloadToolRelease(pm, tool, downloadCB)
8787
}
8888

8989
// 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 {
9191
resp, err := pm.DownloadToolRelease(toolRelease)
9292
if err != nil {
9393
return err
9494
}
95-
return download(resp, toolRelease.String(), progress)
95+
return download(resp, toolRelease.String(), downloadCB)
9696
}
9797

98-
func download(d *downloader.Downloader, label string, progress commands.ProgressCB) error {
98+
func download(d *downloader.Downloader, label string, downloadCB commands.DownloadProgressCB) error {
9999
if d == nil {
100100
// This signal means that the file is already downloaded
101-
progress(&rpc.DownloadProgress{
101+
downloadCB(&rpc.DownloadProgress{
102102
File: label,
103103
Completed: true,
104104
})
105105
return nil
106106
}
107-
progress(&rpc.DownloadProgress{
107+
downloadCB(&rpc.DownloadProgress{
108108
File: label,
109109
Url: d.URL,
110110
TotalSize: d.Size(),
111111
})
112112
d.RunAndPoll(func(downloaded int64) {
113-
progress(&rpc.DownloadProgress{Downloaded: downloaded})
113+
downloadCB(&rpc.DownloadProgress{Downloaded: downloaded})
114114
}, 250*time.Millisecond)
115115
if d.Error() != nil {
116116
return d.Error()
117117
}
118-
progress(&rpc.DownloadProgress{Completed: true})
118+
downloadCB(&rpc.DownloadProgress{Completed: true})
119119
return nil
120120
}

commands/core/install.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
)
1515

1616
func PlatformInstall(ctx context.Context, req *rpc.PlatformInstallReq,
17-
progress commands.ProgressCB, taskCB commands.TaskProgressCB) (*rpc.PlatformInstallResp, error) {
17+
downloadCB commands.DownloadProgressCB, taskCB commands.TaskProgressCB) (*rpc.PlatformInstallResp, error) {
1818
var version *semver.Version
1919
if req.Version != "" {
2020
if v, err := semver.Parse(req.Version); err == nil {
@@ -38,7 +38,7 @@ func PlatformInstall(ctx context.Context, req *rpc.PlatformInstallReq,
3838
return nil, fmt.Errorf("finding platform dependencies: %s", err)
3939
}
4040

41-
err = installPlatform(pm, platform, tools, progress, taskCB)
41+
err = installPlatform(pm, platform, tools, downloadCB, taskCB)
4242
if err != nil {
4343
return nil, err
4444
}
@@ -53,7 +53,7 @@ func PlatformInstall(ctx context.Context, req *rpc.PlatformInstallReq,
5353

5454
func installPlatform(pm *packagemanager.PackageManager,
5555
platformRelease *cores.PlatformRelease, requiredTools []*cores.ToolRelease,
56-
progress commands.ProgressCB, taskCB commands.TaskProgressCB) error {
56+
downloadCB commands.DownloadProgressCB, taskCB commands.TaskProgressCB) error {
5757
log := pm.Log.WithField("platform", platformRelease)
5858

5959
// Prerequisite checks before install
@@ -75,9 +75,9 @@ func installPlatform(pm *packagemanager.PackageManager,
7575
// Package download
7676
taskCB(&rpc.TaskProgress{Name: "Downloading packages"})
7777
for _, tool := range toolsToInstall {
78-
downloadTool(pm, tool, progress)
78+
downloadTool(pm, tool, downloadCB)
7979
}
80-
downloadPlatform(pm, platformRelease, progress)
80+
downloadPlatform(pm, platformRelease, downloadCB)
8181
taskCB(&rpc.TaskProgress{Completed: true})
8282

8383
// Install tools first

commands/core/upgrade.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
)
3030

3131
func PlatformUpgrade(ctx context.Context, req *rpc.PlatformUpgradeReq,
32-
progress commands.ProgressCB, taskCB commands.TaskProgressCB) (*rpc.PlatformUpgradeResp, error) {
32+
downloadCB commands.DownloadProgressCB, taskCB commands.TaskProgressCB) (*rpc.PlatformUpgradeResp, error) {
3333
// Extract all PlatformReference to platforms that have updates
3434
var version *semver.Version
3535
if req.Version != "" {
@@ -48,7 +48,7 @@ func PlatformUpgrade(ctx context.Context, req *rpc.PlatformUpgradeReq,
4848
Package: req.PlatformPackage,
4949
PlatformArchitecture: req.Architecture,
5050
PlatformVersion: version}
51-
err := upgradePlatform(pm, ref, progress, taskCB)
51+
err := upgradePlatform(pm, ref, downloadCB, taskCB)
5252
if err != nil {
5353
return nil, err
5454
}
@@ -62,7 +62,7 @@ func PlatformUpgrade(ctx context.Context, req *rpc.PlatformUpgradeReq,
6262
}
6363

6464
func upgradePlatform(pm *packagemanager.PackageManager, platformRef *packagemanager.PlatformReference,
65-
progress commands.ProgressCB, taskCB commands.TaskProgressCB) error {
65+
downloadCB commands.DownloadProgressCB, taskCB commands.TaskProgressCB) error {
6666
if platformRef.PlatformVersion != nil {
6767
return fmt.Errorf("upgrade doesn't accept parameters with version")
6868
}
@@ -89,7 +89,7 @@ func upgradePlatform(pm *packagemanager.PackageManager, platformRef *packagemana
8989
if err != nil {
9090
return fmt.Errorf("platform %s is not installed", platformRef)
9191
}
92-
err = installPlatform(pm, platform, tools, progress, taskCB)
92+
err = installPlatform(pm, platform, tools, downloadCB, taskCB)
9393
if err != nil {
9494
return err
9595
}

commands/progress.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package commands
22

33
import "github.com/arduino/arduino-cli/rpc"
44

5-
// ProgressCB is a callback to get updates on download progress
6-
type ProgressCB func(curr *rpc.DownloadProgress)
5+
// DownloadProgressCB is a callback to get updates on download progress
6+
type DownloadProgressCB func(curr *rpc.DownloadProgress)
77

88
// TaskProgressCB is a callback to receive progress messages
99
type TaskProgressCB func(msg *rpc.TaskProgress)

daemon/client/client.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ func main() {
156156
os.Exit(1)
157157
}
158158
if resp := uplResp.GetOutStream(); resp != nil {
159-
160159
fmt.Printf("output %s", resp)
161160
}
162161
if resperr := uplResp.GetErrStream(); resperr != nil {

0 commit comments

Comments
 (0)