Skip to content

Commit 66a4f27

Browse files
committed
gRPC: allow cancellation of downloads
1 parent ba19a2d commit 66a4f27

16 files changed

+44
-41
lines changed

.licenses/go/go.bug.st/downloader/v2.dep.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: go.bug.st/downloader/v2
3-
version: v2.1.1
3+
version: v2.2.0
44
type: go
55
summary:
66
homepage: https://pkg.go.dev/go.bug.st/downloader/v2

commands/instances.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ import (
4545
"google.golang.org/grpc/status"
4646
)
4747

48-
func installTool(pm *packagemanager.PackageManager, tool *cores.ToolRelease, downloadCB rpc.DownloadProgressCB, taskCB rpc.TaskProgressCB) error {
48+
func installTool(ctx context.Context, pm *packagemanager.PackageManager, tool *cores.ToolRelease, downloadCB rpc.DownloadProgressCB, taskCB rpc.TaskProgressCB) error {
4949
pme, release := pm.NewExplorer()
5050
defer release()
5151

5252
taskCB(&rpc.TaskProgress{Name: tr("Downloading missing tool %s", tool)})
53-
if err := pme.DownloadToolRelease(tool, downloadCB); err != nil {
53+
if err := pme.DownloadToolRelease(ctx, tool, downloadCB); err != nil {
5454
return fmt.Errorf(tr("downloading %[1]s tool: %[2]s"), tool, err)
5555
}
5656
taskCB(&rpc.TaskProgress{Completed: true})
@@ -283,7 +283,7 @@ func (s *arduinoCoreServerImpl) Init(req *rpc.InitRequest, stream rpc.ArduinoCor
283283
// Install builtin tools if necessary
284284
if len(builtinToolsToInstall) > 0 {
285285
for _, toolRelease := range builtinToolsToInstall {
286-
if err := installTool(pmb.Build(), toolRelease, downloadCallback, taskCallback); err != nil {
286+
if err := installTool(ctx, pmb.Build(), toolRelease, downloadCallback, taskCallback); err != nil {
287287
e := &cmderrors.InitFailedError{
288288
Code: codes.Internal,
289289
Cause: err,
@@ -385,7 +385,7 @@ func (s *arduinoCoreServerImpl) Init(req *rpc.InitRequest, stream rpc.ArduinoCor
385385
responseError(e.GRPCStatus())
386386
continue
387387
}
388-
if err := libRelease.Resource.Download(pme.DownloadDir, config, libRelease.String(), downloadCallback, ""); err != nil {
388+
if err := libRelease.Resource.Download(ctx, pme.DownloadDir, config, libRelease.String(), downloadCallback, ""); err != nil {
389389
taskCallback(&rpc.TaskProgress{Name: tr("Error downloading library %s", libraryRef)})
390390
e := &cmderrors.FailedLibraryInstallError{Cause: err}
391391
responseError(e.GRPCStatus())

commands/service_library_download.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,15 @@ func (s *arduinoCoreServerImpl) LibraryDownload(req *rpc.LibraryDownloadRequest,
8181
})
8282
}
8383

84-
func downloadLibrary(_ context.Context, downloadsDir *paths.Path, libRelease *librariesindex.Release,
84+
func downloadLibrary(ctx context.Context, downloadsDir *paths.Path, libRelease *librariesindex.Release,
8585
downloadCB rpc.DownloadProgressCB, taskCB rpc.TaskProgressCB, queryParameter string, settings *configuration.Settings) error {
8686

8787
taskCB(&rpc.TaskProgress{Name: tr("Downloading %s", libRelease)})
8888
config, err := settings.DownloaderConfig()
8989
if err != nil {
9090
return &cmderrors.FailedDownloadError{Message: tr("Can't download library"), Cause: err}
9191
}
92-
// TODO: Pass context
93-
if err := libRelease.Resource.Download(downloadsDir, config, libRelease.String(), downloadCB, queryParameter); err != nil {
92+
if err := libRelease.Resource.Download(ctx, downloadsDir, config, libRelease.String(), downloadCB, queryParameter); err != nil {
9493
return &cmderrors.FailedDownloadError{Message: tr("Can't download library"), Cause: err}
9594
}
9695
taskCB(&rpc.TaskProgress{Completed: true})

commands/service_platform_download.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ func PlatformDownloadStreamResponseToCallbackFunction(ctx context.Context, downl
4040

4141
// PlatformDownload downloads a platform package
4242
func (s *arduinoCoreServerImpl) PlatformDownload(req *rpc.PlatformDownloadRequest, stream rpc.ArduinoCoreService_PlatformDownloadServer) error {
43+
ctx := stream.Context()
4344
syncSend := NewSynchronizedSend(stream.Send)
4445

4546
pme, release, err := instances.GetPackageManagerExplorer(req.GetInstance())
@@ -71,15 +72,12 @@ func (s *arduinoCoreServerImpl) PlatformDownload(req *rpc.PlatformDownloadReques
7172
})
7273
}
7374

74-
// TODO: pass context
75-
// ctx := stream.Context()
76-
if err := pme.DownloadPlatformRelease(platform, downloadCB); err != nil {
75+
if err := pme.DownloadPlatformRelease(ctx, platform, downloadCB); err != nil {
7776
return err
7877
}
7978

8079
for _, tool := range tools {
81-
// TODO: pass context
82-
if err := pme.DownloadToolRelease(tool, downloadCB); err != nil {
80+
if err := pme.DownloadToolRelease(ctx, tool, downloadCB); err != nil {
8381
return err
8482
}
8583
}

commands/service_platform_install.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@ func (s *arduinoCoreServerImpl) PlatformInstall(req *rpc.PlatformInstallRequest,
9494
}
9595
}
9696

97-
// TODO: Pass context
98-
if err := pme.DownloadAndInstallPlatformAndTools(platformRelease, tools, downloadCB, taskCB, req.GetSkipPostInstall(), req.GetSkipPreUninstall()); err != nil {
97+
if err := pme.DownloadAndInstallPlatformAndTools(ctx, platformRelease, tools, downloadCB, taskCB, req.GetSkipPostInstall(), req.GetSkipPreUninstall()); err != nil {
9998
return err
10099
}
101100

commands/service_platform_upgrade.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func (s *arduinoCoreServerImpl) PlatformUpgrade(req *rpc.PlatformUpgradeRequest,
7575
Package: req.GetPlatformPackage(),
7676
PlatformArchitecture: req.GetArchitecture(),
7777
}
78-
platform, err := pme.DownloadAndInstallPlatformUpgrades(ref, downloadCB, taskCB, req.GetSkipPostInstall(), req.GetSkipPreUninstall())
78+
platform, err := pme.DownloadAndInstallPlatformUpgrades(ctx, ref, downloadCB, taskCB, req.GetSkipPostInstall(), req.GetSkipPreUninstall())
7979
if err != nil {
8080
return platform, err
8181
}

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ require (
3535
github.com/stretchr/testify v1.9.0
3636
github.com/xeipuuv/gojsonschema v1.2.0
3737
go.bug.st/cleanup v1.0.0
38-
go.bug.st/downloader/v2 v2.1.1
38+
go.bug.st/downloader/v2 v2.2.0
3939
go.bug.st/relaxed-semver v0.12.0
4040
go.bug.st/testifyjson v1.1.1
4141
golang.org/x/term v0.20.0

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17
211211
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
212212
go.bug.st/cleanup v1.0.0 h1:XVj1HZxkBXeq3gMT7ijWUpHyIC1j8XAoNSyQ06CskgA=
213213
go.bug.st/cleanup v1.0.0/go.mod h1:EqVmTg2IBk4znLbPD28xne3abjsJftMdqqJEjhn70bk=
214-
go.bug.st/downloader/v2 v2.1.1 h1:nyqbUizo3E2IxCCm4YFac4FtSqqFpqWP+Aae5GCMuw4=
215-
go.bug.st/downloader/v2 v2.1.1/go.mod h1:VZW2V1iGKV8rJL2ZEGIDzzBeKowYv34AedJz13RzVII=
214+
go.bug.st/downloader/v2 v2.2.0 h1:Y0jSuDISNhrzePkrAWqz9xUC3xol9hqZo/+tz1D4EqY=
215+
go.bug.st/downloader/v2 v2.2.0/go.mod h1:VZW2V1iGKV8rJL2ZEGIDzzBeKowYv34AedJz13RzVII=
216216
go.bug.st/relaxed-semver v0.12.0 h1:se8v3lTdAAFp68+/RS/0Y/nFdnpdzkP5ICY04SPau4E=
217217
go.bug.st/relaxed-semver v0.12.0/go.mod h1:Cpcbiig6Omwlq6bS7i3MQWiqS7W7HDd8CAnZFC40Cl0=
218218
go.bug.st/serial v1.6.1 h1:VSSWmUxlj1T/YlRo2J104Zv3wJFrjHIl/T3NeruWAHY=

internal/arduino/cores/packagemanager/download.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package packagemanager
1717

1818
import (
19+
"context"
1920
"errors"
2021
"fmt"
2122

@@ -119,21 +120,21 @@ func (pme *Explorer) FindPlatformReleaseDependencies(item *PlatformReference) (*
119120

120121
// DownloadToolRelease downloads a ToolRelease. If the tool is already downloaded a nil Downloader
121122
// is returned. Uses the given downloader configuration for download, or the default config if nil.
122-
func (pme *Explorer) DownloadToolRelease(tool *cores.ToolRelease, progressCB rpc.DownloadProgressCB) error {
123+
func (pme *Explorer) DownloadToolRelease(ctx context.Context, tool *cores.ToolRelease, progressCB rpc.DownloadProgressCB) error {
123124
resource := tool.GetCompatibleFlavour()
124125
if resource == nil {
125126
return &cmderrors.FailedDownloadError{
126127
Message: tr("Error downloading tool %s", tool),
127128
Cause: errors.New(tr("no versions available for the current OS, try contacting %s", tool.Tool.Package.Email))}
128129
}
129-
return resource.Download(pme.DownloadDir, pme.downloaderConfig, tool.String(), progressCB, "")
130+
return resource.Download(ctx, pme.DownloadDir, pme.downloaderConfig, tool.String(), progressCB, "")
130131
}
131132

132133
// DownloadPlatformRelease downloads a PlatformRelease. If the platform is already downloaded a
133134
// nil Downloader is returned.
134-
func (pme *Explorer) DownloadPlatformRelease(platform *cores.PlatformRelease, progressCB rpc.DownloadProgressCB) error {
135+
func (pme *Explorer) DownloadPlatformRelease(ctx context.Context, platform *cores.PlatformRelease, progressCB rpc.DownloadProgressCB) error {
135136
if platform.Resource == nil {
136137
return &cmderrors.PlatformNotFoundError{Platform: platform.String()}
137138
}
138-
return platform.Resource.Download(pme.DownloadDir, pme.downloaderConfig, platform.String(), progressCB, "")
139+
return platform.Resource.Download(ctx, pme.DownloadDir, pme.downloaderConfig, platform.String(), progressCB, "")
139140
}

internal/arduino/cores/packagemanager/install_uninstall.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package packagemanager
1717

1818
import (
1919
"bytes"
20+
"context"
2021
"encoding/json"
2122
"errors"
2223
"fmt"
@@ -33,6 +34,7 @@ import (
3334
// This method takes care of downloading missing archives, upgrading platforms and tools, and
3435
// removing the previously installed platform/tools that are no longer needed after the upgrade.
3536
func (pme *Explorer) DownloadAndInstallPlatformUpgrades(
37+
ctx context.Context,
3638
platformRef *PlatformReference,
3739
downloadCB rpc.DownloadProgressCB,
3840
taskCB rpc.TaskProgressCB,
@@ -62,7 +64,7 @@ func (pme *Explorer) DownloadAndInstallPlatformUpgrades(
6264
if err != nil {
6365
return nil, &cmderrors.PlatformNotFoundError{Platform: platformRef.String()}
6466
}
65-
if err := pme.DownloadAndInstallPlatformAndTools(platformRelease, tools, downloadCB, taskCB, skipPostInstall, skipPreUninstall); err != nil {
67+
if err := pme.DownloadAndInstallPlatformAndTools(ctx, platformRelease, tools, downloadCB, taskCB, skipPostInstall, skipPreUninstall); err != nil {
6668
return nil, err
6769
}
6870

@@ -73,6 +75,7 @@ func (pme *Explorer) DownloadAndInstallPlatformUpgrades(
7375
// This method takes care of downloading missing archives, installing/upgrading platforms and tools, and
7476
// removing the previously installed platform/tools that are no longer needed after the upgrade.
7577
func (pme *Explorer) DownloadAndInstallPlatformAndTools(
78+
ctx context.Context,
7679
platformRelease *cores.PlatformRelease, requiredTools []*cores.ToolRelease,
7780
downloadCB rpc.DownloadProgressCB, taskCB rpc.TaskProgressCB,
7881
skipPostInstall bool, skipPreUninstall bool) error {
@@ -92,11 +95,11 @@ func (pme *Explorer) DownloadAndInstallPlatformAndTools(
9295
// Package download
9396
taskCB(&rpc.TaskProgress{Name: tr("Downloading packages")})
9497
for _, tool := range toolsToInstall {
95-
if err := pme.DownloadToolRelease(tool, downloadCB); err != nil {
98+
if err := pme.DownloadToolRelease(ctx, tool, downloadCB); err != nil {
9699
return err
97100
}
98101
}
99-
if err := pme.DownloadPlatformRelease(platformRelease, downloadCB); err != nil {
102+
if err := pme.DownloadPlatformRelease(ctx, platformRelease, downloadCB); err != nil {
100103
return err
101104
}
102105
taskCB(&rpc.TaskProgress{Completed: true})

internal/arduino/cores/packagemanager/profiles.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func (pmb *Builder) LoadHardwareForProfile(ctx context.Context, p *sketch.Profil
5757

5858
for _, toolDep := range platformRelease.ToolDependencies {
5959
indexURL := indexURLs[toolDep.ToolPackager]
60-
if err := pmb.loadProfileTool(toolDep, indexURL, installMissing, downloadCB, taskCB, settings); err != nil {
60+
if err := pmb.loadProfileTool(ctx, toolDep, indexURL, installMissing, downloadCB, taskCB, settings); err != nil {
6161
merr = append(merr, fmt.Errorf("%s: %w", tr("loading required tool %s", toolDep), err))
6262
logrus.WithField("tool", toolDep).WithField("index_url", indexURL).WithError(err).Debugf("Error loading tool for profile")
6363
} else {
@@ -122,7 +122,7 @@ func (pmb *Builder) installMissingProfilePlatform(ctx context.Context, platformR
122122
tmpPme, tmpRelease := tmpPm.NewExplorer()
123123
defer tmpRelease()
124124

125-
if err := tmpPme.DownloadPlatformRelease(tmpPlatformRelease, downloadCB); err != nil {
125+
if err := tmpPme.DownloadPlatformRelease(ctx, tmpPlatformRelease, downloadCB); err != nil {
126126
taskCB(&rpc.TaskProgress{Name: tr("Error downloading platform %s", tmpPlatformRelease)})
127127
return &cmderrors.FailedInstallError{Message: tr("Error downloading platform %s", tmpPlatformRelease), Cause: err}
128128
}
@@ -138,7 +138,7 @@ func (pmb *Builder) installMissingProfilePlatform(ctx context.Context, platformR
138138
return nil
139139
}
140140

141-
func (pmb *Builder) loadProfileTool(toolRef *cores.ToolDependency, indexURL *url.URL, installMissing bool, downloadCB rpc.DownloadProgressCB, taskCB rpc.TaskProgressCB, settings *configuration.Settings) error {
141+
func (pmb *Builder) loadProfileTool(ctx context.Context, toolRef *cores.ToolDependency, indexURL *url.URL, installMissing bool, downloadCB rpc.DownloadProgressCB, taskCB rpc.TaskProgressCB, settings *configuration.Settings) error {
142142
targetPackage := pmb.packages.GetOrCreatePackage(toolRef.ToolPackager)
143143
tool := targetPackage.GetOrCreateTool(toolRef.ToolName)
144144

@@ -151,15 +151,15 @@ func (pmb *Builder) loadProfileTool(toolRef *cores.ToolDependency, indexURL *url
151151
if toolRelease == nil {
152152
return &cmderrors.InvalidVersionError{Cause: fmt.Errorf(tr("version %s not found", toolRef.ToolVersion))}
153153
}
154-
if err := pmb.installMissingProfileTool(toolRelease, destDir, downloadCB, taskCB); err != nil {
154+
if err := pmb.installMissingProfileTool(ctx, toolRelease, destDir, downloadCB, taskCB); err != nil {
155155
return err
156156
}
157157
}
158158

159159
return pmb.loadToolReleaseFromDirectory(tool, toolRef.ToolVersion, destDir)
160160
}
161161

162-
func (pmb *Builder) installMissingProfileTool(toolRelease *cores.ToolRelease, destDir *paths.Path, downloadCB rpc.DownloadProgressCB, taskCB rpc.TaskProgressCB) error {
162+
func (pmb *Builder) installMissingProfileTool(ctx context.Context, toolRelease *cores.ToolRelease, destDir *paths.Path, downloadCB rpc.DownloadProgressCB, taskCB rpc.TaskProgressCB) error {
163163
// Instantiate a temporary package manager only for platform installation
164164
tmp, err := paths.MkTempDir(destDir.Parent().String(), "")
165165
if err != nil {
@@ -173,7 +173,7 @@ func (pmb *Builder) installMissingProfileTool(toolRelease *cores.ToolRelease, de
173173
return &cmderrors.InvalidVersionError{Cause: fmt.Errorf(tr("version %s not available for this operating system", toolRelease))}
174174
}
175175
taskCB(&rpc.TaskProgress{Name: tr("Downloading tool %s", toolRelease)})
176-
if err := toolResource.Download(pmb.DownloadDir, pmb.downloaderConfig, toolRelease.String(), downloadCB, ""); err != nil {
176+
if err := toolResource.Download(ctx, pmb.DownloadDir, pmb.downloaderConfig, toolRelease.String(), downloadCB, ""); err != nil {
177177
taskCB(&rpc.TaskProgress{Name: tr("Error downloading tool %s", toolRelease)})
178178
return &cmderrors.FailedInstallError{Message: tr("Error installing tool %s", toolRelease), Cause: err}
179179
}

internal/arduino/httpclient/httpclient.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package httpclient
1717

1818
import (
19+
"context"
1920
"time"
2021

2122
"github.com/arduino/arduino-cli/commands/cmderrors"
@@ -31,7 +32,7 @@ var tr = i18n.Tr
3132
// DownloadFile downloads a file from a URL into the specified path. An optional config and options may be passed (or nil to use the defaults).
3233
// A DownloadProgressCB callback function must be passed to monitor download progress.
3334
// If a not empty queryParameter is passed, it is appended to the URL for analysis purposes.
34-
func DownloadFile(path *paths.Path, URL string, queryParameter string, label string, downloadCB rpc.DownloadProgressCB, config downloader.Config, options ...downloader.DownloadOptions) (returnedError error) {
35+
func DownloadFile(ctx context.Context, path *paths.Path, URL string, queryParameter string, label string, downloadCB rpc.DownloadProgressCB, config downloader.Config, options ...downloader.DownloadOptions) (returnedError error) {
3536
if queryParameter != "" {
3637
URL = URL + "?query=" + queryParameter
3738
}
@@ -45,7 +46,7 @@ func DownloadFile(path *paths.Path, URL string, queryParameter string, label str
4546
}
4647
}()
4748

48-
d, err := downloader.DownloadWithConfig(path.String(), URL, config, options...)
49+
d, err := downloader.DownloadWithConfigAndContext(ctx, path.String(), URL, config, options...)
4950
if err != nil {
5051
return err
5152
}

internal/arduino/resources/download.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package resources
1717

1818
import (
19+
"context"
1920
"fmt"
2021
"os"
2122

@@ -28,7 +29,7 @@ import (
2829
// Download performs a download loop using the provided downloader.Config.
2930
// Messages are passed back to the DownloadProgressCB using label as text for the File field.
3031
// queryParameter is passed for analysis purposes.
31-
func (r *DownloadResource) Download(downloadDir *paths.Path, config downloader.Config, label string, downloadCB rpc.DownloadProgressCB, queryParameter string) error {
32+
func (r *DownloadResource) Download(ctx context.Context, downloadDir *paths.Path, config downloader.Config, label string, downloadCB rpc.DownloadProgressCB, queryParameter string) error {
3233
path, err := r.ArchivePath(downloadDir)
3334
if err != nil {
3435
return fmt.Errorf(tr("getting archive path: %s"), err)
@@ -52,5 +53,5 @@ func (r *DownloadResource) Download(downloadDir *paths.Path, config downloader.C
5253
} else {
5354
return fmt.Errorf(tr("getting archive file info: %s"), err)
5455
}
55-
return httpclient.DownloadFile(path, r.URL, queryParameter, label, downloadCB, config)
56+
return httpclient.DownloadFile(ctx, path, r.URL, queryParameter, label, downloadCB, config)
5657
}

internal/arduino/resources/helpers_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package resources
1717

1818
import (
19+
"context"
1920
"net/http"
2021
"net/http/httptest"
2122
"os"
@@ -56,7 +57,7 @@ func TestDownloadApplyUserAgentHeaderUsingConfig(t *testing.T) {
5657
settings.Set("network.user_agent_ext", goldUserAgentValue)
5758
config, err := settings.DownloaderConfig()
5859
require.NoError(t, err)
59-
err = r.Download(tmp, config, "", func(progress *rpc.DownloadProgress) {}, "")
60+
err = r.Download(context.Background(), tmp, config, "", func(progress *rpc.DownloadProgress) {}, "")
6061
require.NoError(t, err)
6162

6263
// leverage the download helper to download the echo for the request made by the downloader itself

internal/arduino/resources/index.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func (res *IndexResource) Download(ctx context.Context, destDir *paths.Path, dow
7878
return err
7979
}
8080
tmpIndexPath := tmp.Join(downloadFileName)
81-
if err := httpclient.DownloadFile(tmpIndexPath, res.URL.String(), "", tr("Downloading index: %s", downloadFileName), downloadCB, config, downloader.NoResume); err != nil {
81+
if err := httpclient.DownloadFile(ctx, tmpIndexPath, res.URL.String(), "", tr("Downloading index: %s", downloadFileName), downloadCB, config, downloader.NoResume); err != nil {
8282
return &cmderrors.FailedDownloadError{Message: tr("Error downloading index '%s'", res.URL), Cause: err}
8383
}
8484

@@ -133,7 +133,7 @@ func (res *IndexResource) Download(ctx context.Context, destDir *paths.Path, dow
133133
// Download signature
134134
signaturePath = destDir.Join(signatureFileName)
135135
tmpSignaturePath = tmp.Join(signatureFileName)
136-
if err := httpclient.DownloadFile(tmpSignaturePath, res.SignatureURL.String(), "", tr("Downloading index signature: %s", signatureFileName), downloadCB, config, downloader.NoResume); err != nil {
136+
if err := httpclient.DownloadFile(ctx, tmpSignaturePath, res.SignatureURL.String(), "", tr("Downloading index signature: %s", signatureFileName), downloadCB, config, downloader.NoResume); err != nil {
137137
return &cmderrors.FailedDownloadError{Message: tr("Error downloading index signature '%s'", res.SignatureURL), Cause: err}
138138
}
139139

internal/arduino/resources/resources_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func TestDownloadAndChecksums(t *testing.T) {
5050
require.NoError(t, err)
5151

5252
downloadAndTestChecksum := func() {
53-
err := r.Download(tmp, downloader.Config{}, "", func(*rpc.DownloadProgress) {}, "")
53+
err := r.Download(context.Background(), tmp, downloader.Config{}, "", func(*rpc.DownloadProgress) {}, "")
5454
require.NoError(t, err)
5555

5656
data, err := testFile.ReadFile()
@@ -64,7 +64,7 @@ func TestDownloadAndChecksums(t *testing.T) {
6464
downloadAndTestChecksum()
6565

6666
// Download with cached file
67-
err = r.Download(tmp, downloader.Config{}, "", func(*rpc.DownloadProgress) {}, "")
67+
err = r.Download(context.Background(), tmp, downloader.Config{}, "", func(*rpc.DownloadProgress) {}, "")
6868
require.NoError(t, err)
6969

7070
// Download if cached file has data in excess (redownload)

0 commit comments

Comments
 (0)