Skip to content

Commit 8b366d3

Browse files
Remove query parameter where it is not needed
1 parent 271d241 commit 8b366d3

File tree

5 files changed

+13
-17
lines changed

5 files changed

+13
-17
lines changed

Diff for: commands/daemon/daemon.go

-1
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,6 @@ func (s *ArduinoCoreServerImpl) LibraryInstall(req *rpc.LibraryInstallRequest, s
357357
stream.Context(), req,
358358
func(p *rpc.DownloadProgress) { stream.Send(&rpc.LibraryInstallResponse{Progress: p}) },
359359
func(p *rpc.TaskProgress) { stream.Send(&rpc.LibraryInstallResponse{TaskProgress: p}) },
360-
"",
361360
)
362361
if err != nil {
363362
return convertErrorToRPCStatus(err)

Diff for: commands/lib/install.go

+11-13
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import (
3232

3333
// LibraryInstall resolves the library dependencies, then downloads and installs the libraries into the install location.
3434
// 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 {
35+
func LibraryInstall(ctx context.Context, req *rpc.LibraryInstallRequest, downloadCB rpc.DownloadProgressCB, taskCB rpc.TaskProgressCB) error {
3636
lm := commands.GetLibraryManager(req)
3737
if lm == nil {
3838
return &arduino.InvalidInstanceError{}
@@ -98,21 +98,19 @@ func LibraryInstall(ctx context.Context, req *rpc.LibraryInstallRequest, downloa
9898

9999
for libRelease, installTask := range libReleasesToInstall {
100100
// Checks if libRelease is the requested library and not a dependency
101+
downloadReason := "depends"
101102
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
103+
downloadReason = "install"
104+
if installTask.ReplacedLib != nil {
105+
downloadReason = "upgrade"
114106
}
115107
}
108+
if err := downloadLibrary(lm, libRelease, downloadCB, taskCB, downloadReason); err != nil {
109+
return err
110+
}
111+
if err := installLibrary(lm, libRelease, installTask, taskCB); err != nil {
112+
return err
113+
}
116114
}
117115

118116
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/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)