Skip to content

[skip-changelog] Remove queryParameter where it is not needed #2036

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions commands/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,6 @@ func (s *ArduinoCoreServerImpl) LibraryDownload(req *rpc.LibraryDownloadRequest,
resp, err := lib.LibraryDownload(
stream.Context(), req,
func(p *rpc.DownloadProgress) { stream.Send(&rpc.LibraryDownloadResponse{Progress: p}) },
"",
)
if err != nil {
return convertErrorToRPCStatus(err)
Expand All @@ -357,7 +356,6 @@ func (s *ArduinoCoreServerImpl) LibraryInstall(req *rpc.LibraryInstallRequest, s
stream.Context(), req,
func(p *rpc.DownloadProgress) { stream.Send(&rpc.LibraryInstallResponse{Progress: p}) },
func(p *rpc.TaskProgress) { stream.Send(&rpc.LibraryInstallResponse{TaskProgress: p}) },
"",
)
if err != nil {
return convertErrorToRPCStatus(err)
Expand Down
5 changes: 2 additions & 3 deletions commands/lib/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ var tr = i18n.Tr

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

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

if err := downloadLibrary(lm, lib, downloadCB, func(*rpc.TaskProgress) {}, queryParameter); err != nil {
if err := downloadLibrary(lm, lib, downloadCB, func(*rpc.TaskProgress) {}, "download"); err != nil {
return nil, err
}

Expand Down
25 changes: 11 additions & 14 deletions commands/lib/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ import (
)

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

for libRelease, installTask := range libReleasesToInstall {
// Checks if libRelease is the requested library and not a dependency
downloadReason := "depends"
if libRelease.GetName() == req.Name {
if err := downloadLibrary(lm, libRelease, downloadCB, taskCB, queryParameter); err != nil {
return err
}
if err := installLibrary(lm, libRelease, installTask, taskCB); err != nil {
return err
}
} else {
if err := downloadLibrary(lm, libRelease, downloadCB, taskCB, "depends"); err != nil {
return err
}
if err := installLibrary(lm, libRelease, installTask, taskCB); err != nil {
return err
downloadReason = "install"
if installTask.ReplacedLib != nil {
downloadReason = "upgrade"
}
}
if err := downloadLibrary(lm, libRelease, downloadCB, taskCB, downloadReason); err != nil {
return err
}
if err := installLibrary(lm, libRelease, installTask, taskCB); err != nil {
return err
}
}

if err := commands.Init(&rpc.InitRequest{Instance: req.Instance}, nil); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion commands/lib/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func upgrade(instance *rpc.Instance, libs []*installedLib, downloadCB rpc.Downlo
NoDeps: false,
NoOverwrite: false,
}
err := LibraryInstall(context.Background(), libInstallReq, downloadCB, taskCB, "upgrade")
err := LibraryInstall(context.Background(), libInstallReq, downloadCB, taskCB)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/lib/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func runDownloadCommand(cmd *cobra.Command, args []string) {
Name: library.Name,
Version: library.Version,
}
_, err := lib.LibraryDownload(context.Background(), libraryDownloadRequest, feedback.ProgressBar(), "download")
_, err := lib.LibraryDownload(context.Background(), libraryDownloadRequest, feedback.ProgressBar())
if err != nil {
feedback.Fatal(tr("Error downloading %[1]s: %[2]v", library, err), feedback.ErrNetwork)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/lib/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func runInstallCommand(cmd *cobra.Command, args []string) {
NoDeps: noDeps,
NoOverwrite: noOverwrite,
}
err := lib.LibraryInstall(context.Background(), libraryInstallRequest, feedback.ProgressBar(), feedback.TaskProgress(), "install")
err := lib.LibraryInstall(context.Background(), libraryInstallRequest, feedback.ProgressBar(), feedback.TaskProgress())
if err != nil {
feedback.Fatal(tr("Error installing %s: %v", libRef.Name, err), feedback.ErrGeneric)
}
Expand Down
1 change: 0 additions & 1 deletion internal/integrationtest/lib/lib_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1518,5 +1518,4 @@ func TestLibQueryParameters(t *testing.T) {
require.NoError(t, err)
require.Contains(t, string(stdout),
"Starting download \x1b[36murl\x1b[0m=\"https://downloads.arduino.cc/libraries/github.com/arduino-libraries/WiFi101-0.16.1.zip?query=download\"\n")

}