Skip to content

Commit 895b357

Browse files
committed
Moved downloadToolRelease into the proper packagamanger method
1 parent 562c595 commit 895b357

File tree

4 files changed

+6
-38
lines changed

4 files changed

+6
-38
lines changed

arduino/cores/packagemanager/download.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,13 @@ func (pm *PackageManager) FindPlatformReleaseDependencies(item *PlatformReferenc
118118
}
119119

120120
// DownloadToolRelease downloads a ToolRelease. If the tool is already downloaded a nil Downloader
121-
// is returned.
122-
func (pm *PackageManager) DownloadToolRelease(tool *cores.ToolRelease, config *downloader.Config, label string, progressCB rpc.DownloadProgressCB) error {
121+
// is returned. Uses the given downloader configuration for download, or the default config if nil.
122+
func (pm *PackageManager) DownloadToolRelease(tool *cores.ToolRelease, config *downloader.Config, progressCB rpc.DownloadProgressCB) error {
123123
resource := tool.GetCompatibleFlavour()
124124
if resource == nil {
125125
return fmt.Errorf(tr("tool not available for your OS"))
126126
}
127-
return resource.Download(pm.DownloadDir, config, label, progressCB)
127+
return resource.Download(pm.DownloadDir, config, tool.String(), progressCB)
128128
}
129129

130130
// DownloadPlatformRelease downloads a PlatformRelease. If the platform is already downloaded a

commands/bundled_tools.go

Lines changed: 0 additions & 32 deletions
This file was deleted.

commands/core/download.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func downloadTool(pm *packagemanager.PackageManager, tool *cores.ToolRelease, do
8282
Cause: errors.New(tr("no versions available for the current OS", tool))}
8383
}
8484

85-
if err := commands.DownloadToolRelease(pm, tool, downloadCB); err != nil {
85+
if err := pm.DownloadToolRelease(tool, nil, downloadCB); err != nil {
8686
return &arduino.FailedDownloadError{Message: tr("Error downloading tool %s", tool), Cause: err}
8787
}
8888

commands/instances.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func (instance *CoreInstance) installToolIfMissing(tool *cores.ToolRelease, down
9595
return false, nil
9696
}
9797
taskCB(&rpc.TaskProgress{Name: tr("Downloading missing tool %s", tool)})
98-
if err := DownloadToolRelease(instance.PackageManager, tool, downloadCB); err != nil {
98+
if err := instance.PackageManager.DownloadToolRelease(tool, nil, downloadCB); err != nil {
9999
return false, fmt.Errorf(tr("downloading %[1]s tool: %[2]s"), tool, err)
100100
}
101101
taskCB(&rpc.TaskProgress{Completed: true})
@@ -740,7 +740,7 @@ func Upgrade(ctx context.Context, req *rpc.UpgradeRequest, downloadCB rpc.Downlo
740740

741741
// Downloads platform tools
742742
for _, tool := range toolsToInstall {
743-
if err := DownloadToolRelease(pm, tool, downloadCB); err != nil {
743+
if err := pm.DownloadToolRelease(tool, nil, downloadCB); err != nil {
744744
taskCB(&rpc.TaskProgress{Message: tr("Error downloading tool %s", tool)})
745745
return &arduino.FailedDownloadError{Message: tr("Error downloading tool %s", tool), Cause: err}
746746
}

0 commit comments

Comments
 (0)