Skip to content

Commit 69c5fd0

Browse files
cmaglieper1234
andcommitted
Applied suggestions from code review
Co-authored-by: per1234 <accounts@perglass.com>
1 parent e0e3506 commit 69c5fd0

File tree

4 files changed

+28
-12
lines changed

4 files changed

+28
-12
lines changed

arduino/resources/download.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
"go.bug.st/downloader/v2"
2626
)
2727

28-
// Download performs a download loop using the provided downloader.Downloader.
28+
// Download performs a download loop using the provided downloader.Config.
2929
// Messages are passed back to the DownloadProgressCB using label as text for the File field.
3030
func (r *DownloadResource) Download(downloadDir *paths.Path, config *downloader.Config, label string, downloadCB rpc.DownloadProgressCB) error {
3131
path, err := r.ArchivePath(downloadDir)

arduino/resources/index.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
"go.bug.st/downloader/v2"
2929
)
3030

31-
// IndexResource is a reference to a package_index.json
31+
// IndexResource is a reference to an index file URL with an optional signature.
3232
type IndexResource struct {
3333
URL *url.URL
3434
SignatureURL *url.URL

configuration/network.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"github.com/spf13/viper"
2525
)
2626

27-
// UserAgent returns the user agent for the cli (mainly used by http clients)
27+
// UserAgent returns the user agent (mainly used by HTTP clients)
2828
func UserAgent(settings *viper.Viper) string {
2929
subComponent := settings.GetString("network.user_agent_ext")
3030
if subComponent != "" {
@@ -39,7 +39,7 @@ func UserAgent(settings *viper.Viper) string {
3939
globals.VersionInfo.Commit)
4040
}
4141

42-
// NetworkProxy returns the proxy configuration (mainly used by http clients)
42+
// NetworkProxy returns the proxy configuration (mainly used by HTTP clients)
4343
func NetworkProxy(settings *viper.Viper) (*url.URL, error) {
4444
if !settings.IsSet("network.proxy") {
4545
return nil, nil

docs/UPGRADING.md

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,15 @@ Here you can find a list of migration guides to handle breaking changes between
44

55
## 0.22.0
66

7-
### package `github.com/arduino/arduino-cli/httpclient` has been moved to `github.com/arduino/arduino-cli/arduino/httpclient`
7+
### The content of package `github.com/arduino/arduino-cli/httpclient` has been moved to a different path
88

9-
The old import must be updated to the new one.
9+
In particular:
10+
11+
- `UserAgent` and `NetworkProxy` have been moved to `github.com/arduino/arduino-cli/configuration`
12+
- the remainder of the package `github.com/arduino/arduino-cli/httpclient` has been moved to
13+
`github.com/arduino/arduino-cli/arduino/httpclient`
14+
15+
The old imports must be updated according to the list above.
1016

1117
### `commands.DownloadProgressCB` and `commands.TaskProgressCB` have been moved to package `github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1`
1218

@@ -20,7 +26,7 @@ All references to this function must be updated with the new import.
2026

2127
The old function must be replaced by the new one that is much more versatile.
2228

23-
### `packagemanager.PackageManager.DownloadToolRelease`, `packagemanager.PackageManager.DownloadPlatformRelease`, and `resources.DownloadResource.Download` functions now require `label` and `progressCB` parameters
29+
### `packagemanager.PackageManager.DownloadToolRelease`, `packagemanager.PackageManager.DownloadPlatformRelease`, and `resources.DownloadResource.Download` functions change signature and behaviour
2430

2531
The following functions:
2632

@@ -30,22 +36,32 @@ func (pm *PackageManager) DownloadPlatformRelease(platform *cores.PlatformReleas
3036
func (r *DownloadResource) Download(downloadDir *paths.Path, config *downloader.Config) (*downloader.Downloader, error)
3137
```
3238

33-
now requires a progress callback:
39+
now requires a label and a progress callback parameter, do not return the `Downloader` object anymore, and they
40+
automatically handles the download internally:
3441

3542
```go
3643
func (pm *PackageManager) DownloadToolRelease(tool *cores.ToolRelease, config *downloader.Config, label string, progressCB rpc.DownloadProgressCB) error
3744
func (pm *PackageManager) DownloadPlatformRelease(platform *cores.PlatformRelease, config *downloader.Config, label string, progressCB rpc.DownloadProgressCB) error
3845
func (r *DownloadResource) Download(downloadDir *paths.Path, config *downloader.Config, label string, downloadCB rpc.DownloadProgressCB) error
3946
```
4047

41-
The new parameters must be added to legacy code. If progress reports are not needed an empty stub for `label` and
42-
`progressCB` must be provided, for example:
48+
The new progress parameters must be added to legacy code, if progress reports are not needed an empty stub for `label`
49+
and `progressCB` must be provided. There is no more need to execute the `downloader.Run()` or
50+
`downloader.RunAndPoll(...)` method.
51+
52+
For example, the old legacy code like:
4353

4454
```go
45-
err := pm.DownloadPlatformRelease(platformToDownload, config)
55+
downloader, err := pm.DownloadPlatformRelease(platformToDownload, config)
56+
if err != nil {
57+
...
58+
}
59+
if err := downloader.Run(); err != nil {
60+
...
61+
}
4662
```
4763

48-
becomes:
64+
may be ported to the new version as:
4965

5066
```go
5167
err := pm.DownloadPlatformRelease(platformToDownload, config, "", func(progress *rpc.DownloadProgress) {})

0 commit comments

Comments
 (0)