Skip to content

Commit 1897368

Browse files
[skip-changelog] Remove query parameter where it is not needed (#2036)
1 parent 271d241 commit 1897368

File tree

7 files changed

+16
-23
lines changed

7 files changed

+16
-23
lines changed

Diff for: commands/daemon/daemon.go

-2
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,6 @@ func (s *ArduinoCoreServerImpl) LibraryDownload(req *rpc.LibraryDownloadRequest,
343343
resp, err := lib.LibraryDownload(
344344
stream.Context(), req,
345345
func(p *rpc.DownloadProgress) { stream.Send(&rpc.LibraryDownloadResponse{Progress: p}) },
346-
"",
347346
)
348347
if err != nil {
349348
return convertErrorToRPCStatus(err)
@@ -357,7 +356,6 @@ func (s *ArduinoCoreServerImpl) LibraryInstall(req *rpc.LibraryInstallRequest, s
357356
stream.Context(), req,
358357
func(p *rpc.DownloadProgress) { stream.Send(&rpc.LibraryInstallResponse{Progress: p}) },
359358
func(p *rpc.TaskProgress) { stream.Send(&rpc.LibraryInstallResponse{TaskProgress: p}) },
360-
"",
361359
)
362360
if err != nil {
363361
return convertErrorToRPCStatus(err)

Diff for: commands/lib/download.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ var tr = i18n.Tr
3232

3333
// LibraryDownload executes the download of the library.
3434
// A DownloadProgressCB callback function must be passed to monitor download progress.
35-
// queryParameter is passed for analysis purposes.
36-
func LibraryDownload(ctx context.Context, req *rpc.LibraryDownloadRequest, downloadCB rpc.DownloadProgressCB, queryParameter string) (*rpc.LibraryDownloadResponse, error) {
35+
func LibraryDownload(ctx context.Context, req *rpc.LibraryDownloadRequest, downloadCB rpc.DownloadProgressCB) (*rpc.LibraryDownloadResponse, error) {
3736
logrus.Info("Executing `arduino-cli lib download`")
3837

3938
lm := commands.GetLibraryManager(req)
@@ -48,7 +47,7 @@ func LibraryDownload(ctx context.Context, req *rpc.LibraryDownloadRequest, downl
4847
return nil, err
4948
}
5049

51-
if err := downloadLibrary(lm, lib, downloadCB, func(*rpc.TaskProgress) {}, queryParameter); err != nil {
50+
if err := downloadLibrary(lm, lib, downloadCB, func(*rpc.TaskProgress) {}, "download"); err != nil {
5251
return nil, err
5352
}
5453

Diff for: commands/lib/install.go

+11-14
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ import (
3131
)
3232

3333
// LibraryInstall resolves the library dependencies, then downloads and installs the libraries into the install location.
34-
// queryParameter is passed for analysis purposes and forwarded to the called functions. It is set to "depends" when a dependency is installed
35-
func LibraryInstall(ctx context.Context, req *rpc.LibraryInstallRequest, downloadCB rpc.DownloadProgressCB, taskCB rpc.TaskProgressCB, queryParameter string) error {
34+
func LibraryInstall(ctx context.Context, req *rpc.LibraryInstallRequest, downloadCB rpc.DownloadProgressCB, taskCB rpc.TaskProgressCB) error {
3635
lm := commands.GetLibraryManager(req)
3736
if lm == nil {
3837
return &arduino.InvalidInstanceError{}
@@ -98,21 +97,19 @@ func LibraryInstall(ctx context.Context, req *rpc.LibraryInstallRequest, downloa
9897

9998
for libRelease, installTask := range libReleasesToInstall {
10099
// Checks if libRelease is the requested library and not a dependency
100+
downloadReason := "depends"
101101
if libRelease.GetName() == req.Name {
102-
if err := downloadLibrary(lm, libRelease, downloadCB, taskCB, queryParameter); err != nil {
103-
return err
104-
}
105-
if err := installLibrary(lm, libRelease, installTask, taskCB); err != nil {
106-
return err
107-
}
108-
} else {
109-
if err := downloadLibrary(lm, libRelease, downloadCB, taskCB, "depends"); err != nil {
110-
return err
111-
}
112-
if err := installLibrary(lm, libRelease, installTask, taskCB); err != nil {
113-
return err
102+
downloadReason = "install"
103+
if installTask.ReplacedLib != nil {
104+
downloadReason = "upgrade"
114105
}
115106
}
107+
if err := downloadLibrary(lm, libRelease, downloadCB, taskCB, downloadReason); err != nil {
108+
return err
109+
}
110+
if err := installLibrary(lm, libRelease, installTask, taskCB); err != nil {
111+
return err
112+
}
116113
}
117114

118115
if err := commands.Init(&rpc.InitRequest{Instance: req.Instance}, nil); err != nil {

Diff for: commands/lib/upgrade.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func upgrade(instance *rpc.Instance, libs []*installedLib, downloadCB rpc.Downlo
7373
NoDeps: false,
7474
NoOverwrite: false,
7575
}
76-
err := LibraryInstall(context.Background(), libInstallReq, downloadCB, taskCB, "upgrade")
76+
err := LibraryInstall(context.Background(), libInstallReq, downloadCB, taskCB)
7777
if err != nil {
7878
return err
7979
}

Diff for: internal/cli/lib/download.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func runDownloadCommand(cmd *cobra.Command, args []string) {
6060
Name: library.Name,
6161
Version: library.Version,
6262
}
63-
_, err := lib.LibraryDownload(context.Background(), libraryDownloadRequest, feedback.ProgressBar(), "download")
63+
_, err := lib.LibraryDownload(context.Background(), libraryDownloadRequest, feedback.ProgressBar())
6464
if err != nil {
6565
feedback.Fatal(tr("Error downloading %[1]s: %[2]v", library, err), feedback.ErrNetwork)
6666
}

Diff for: internal/cli/lib/install.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func runInstallCommand(cmd *cobra.Command, args []string) {
130130
NoDeps: noDeps,
131131
NoOverwrite: noOverwrite,
132132
}
133-
err := lib.LibraryInstall(context.Background(), libraryInstallRequest, feedback.ProgressBar(), feedback.TaskProgress(), "install")
133+
err := lib.LibraryInstall(context.Background(), libraryInstallRequest, feedback.ProgressBar(), feedback.TaskProgress())
134134
if err != nil {
135135
feedback.Fatal(tr("Error installing %s: %v", libRef.Name, err), feedback.ErrGeneric)
136136
}

Diff for: internal/integrationtest/lib/lib_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -1518,5 +1518,4 @@ func TestLibQueryParameters(t *testing.T) {
15181518
require.NoError(t, err)
15191519
require.Contains(t, string(stdout),
15201520
"Starting download \x1b[36murl\x1b[0m=\"https://downloads.arduino.cc/libraries/github.com/arduino-libraries/WiFi101-0.16.1.zip?query=download\"\n")
1521-
15221521
}

0 commit comments

Comments
 (0)