Unverified Commit 18973684 authored by MatteoPologruto's avatar MatteoPologruto Committed by GitHub

[skip-changelog] Remove query parameter where it is not needed (#2036)

parent 271d241e
......@@ -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)
......@@ -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)
......
......@@ -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)
......@@ -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
}
......
......@@ -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{}
......@@ -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 {
......
......@@ -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
}
......
......@@ -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)
}
......
......@@ -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)
}
......
......@@ -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")
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment