Skip to content

Commit dbd6b01

Browse files
committed
Now GetLibraryManager accepts an rpc.InstanceCommand
1 parent 316d1d3 commit dbd6b01

File tree

9 files changed

+16
-16
lines changed

9 files changed

+16
-16
lines changed

commands/compile/compile.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream
6363
}
6464
defer release()
6565

66-
lm := commands.GetLibraryManager(req.GetInstance().GetId())
66+
lm := commands.GetLibraryManager(req)
6767
if lm == nil {
6868
return nil, &arduino.InvalidInstanceError{}
6969
}

commands/daemon/daemon.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ func (s *ArduinoCoreServerImpl) LibraryUninstall(req *rpc.LibraryUninstallReques
436436

437437
// LibraryUpgradeAll FIXMEDOC
438438
func (s *ArduinoCoreServerImpl) LibraryUpgradeAll(req *rpc.LibraryUpgradeAllRequest, stream rpc.ArduinoCoreService_LibraryUpgradeAllServer) error {
439-
err := lib.LibraryUpgradeAll(req.GetInstance().GetId(),
439+
err := lib.LibraryUpgradeAll(req,
440440
func(p *rpc.DownloadProgress) { stream.Send(&rpc.LibraryUpgradeAllResponse{Progress: p}) },
441441
func(p *rpc.TaskProgress) { stream.Send(&rpc.LibraryUpgradeAllResponse{TaskProgress: p}) },
442442
)

commands/instances.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ func GetPackageManagerExplorer(req rpc.InstanceCommand) (explorer *packagemanage
121121
return pm.NewExplorer()
122122
}
123123

124-
// GetLibraryManager returns the library manager for the given instance ID
125-
func GetLibraryManager(id int32) *librariesmanager.LibrariesManager {
126-
i := instances.GetInstance(id)
124+
// GetLibraryManager returns the library manager for the given instance.
125+
func GetLibraryManager(req rpc.InstanceCommand) *librariesmanager.LibrariesManager {
126+
i := instances.GetInstance(req.GetInstance().GetId())
127127
if i == nil {
128128
return nil
129129
}
@@ -467,7 +467,7 @@ func Destroy(ctx context.Context, req *rpc.DestroyRequest) (*rpc.DestroyResponse
467467
// UpdateLibrariesIndex updates the library_index.json
468468
func UpdateLibrariesIndex(ctx context.Context, req *rpc.UpdateLibrariesIndexRequest, downloadCB rpc.DownloadProgressCB) error {
469469
logrus.Info("Updating libraries index")
470-
lm := GetLibraryManager(req.GetInstance().GetId())
470+
lm := GetLibraryManager(req)
471471
if lm == nil {
472472
return &arduino.InvalidInstanceError{}
473473
}

commands/lib/download.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ var tr = i18n.Tr
3434
func LibraryDownload(ctx context.Context, req *rpc.LibraryDownloadRequest, downloadCB rpc.DownloadProgressCB) (*rpc.LibraryDownloadResponse, error) {
3535
logrus.Info("Executing `arduino-cli lib download`")
3636

37-
lm := commands.GetLibraryManager(req.GetInstance().GetId())
37+
lm := commands.GetLibraryManager(req)
3838
if lm == nil {
3939
return nil, &arduino.InvalidInstanceError{}
4040
}

commands/lib/install.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131
// LibraryInstall FIXMEDOC
3232
func LibraryInstall(ctx context.Context, req *rpc.LibraryInstallRequest, downloadCB rpc.DownloadProgressCB, taskCB rpc.TaskProgressCB) error {
3333

34-
lm := commands.GetLibraryManager(req.GetInstance().GetId())
34+
lm := commands.GetLibraryManager(req)
3535
if lm == nil {
3636
return &arduino.InvalidInstanceError{}
3737
}
@@ -148,19 +148,19 @@ func installLibrary(lm *librariesmanager.LibrariesManager, libRelease *libraries
148148
return nil
149149
}
150150

151-
//ZipLibraryInstall FIXMEDOC
151+
// ZipLibraryInstall FIXMEDOC
152152
func ZipLibraryInstall(ctx context.Context, req *rpc.ZipLibraryInstallRequest, taskCB rpc.TaskProgressCB) error {
153-
lm := commands.GetLibraryManager(req.GetInstance().GetId())
153+
lm := commands.GetLibraryManager(req)
154154
if err := lm.InstallZipLib(ctx, req.Path, req.Overwrite); err != nil {
155155
return &arduino.FailedLibraryInstallError{Cause: err}
156156
}
157157
taskCB(&rpc.TaskProgress{Message: tr("Library installed"), Completed: true})
158158
return nil
159159
}
160160

161-
//GitLibraryInstall FIXMEDOC
161+
// GitLibraryInstall FIXMEDOC
162162
func GitLibraryInstall(ctx context.Context, req *rpc.GitLibraryInstallRequest, taskCB rpc.TaskProgressCB) error {
163-
lm := commands.GetLibraryManager(req.GetInstance().GetId())
163+
lm := commands.GetLibraryManager(req)
164164
if err := lm.InstallGitLib(req.Url, req.Overwrite); err != nil {
165165
return &arduino.FailedLibraryInstallError{Cause: err}
166166
}

commands/lib/list.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func LibraryList(ctx context.Context, req *rpc.LibraryListRequest) (*rpc.Library
4141
}
4242
defer release()
4343

44-
lm := commands.GetLibraryManager(req.GetInstance().GetId())
44+
lm := commands.GetLibraryManager(req)
4545
if lm == nil {
4646
return nil, &arduino.InvalidInstanceError{}
4747
}

commands/lib/resolve_deps.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727

2828
// LibraryResolveDependencies FIXMEDOC
2929
func LibraryResolveDependencies(ctx context.Context, req *rpc.LibraryResolveDependenciesRequest) (*rpc.LibraryResolveDependenciesResponse, error) {
30-
lm := commands.GetLibraryManager(req.GetInstance().GetId())
30+
lm := commands.GetLibraryManager(req)
3131
if lm == nil {
3232
return nil, &arduino.InvalidInstanceError{}
3333
}

commands/lib/search.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929

3030
// LibrarySearch FIXMEDOC
3131
func LibrarySearch(ctx context.Context, req *rpc.LibrarySearchRequest) (*rpc.LibrarySearchResponse, error) {
32-
lm := commands.GetLibraryManager(req.GetInstance().GetId())
32+
lm := commands.GetLibraryManager(req)
3333
if lm == nil {
3434
return nil, &arduino.InvalidInstanceError{}
3535
}

commands/lib/uninstall.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525

2626
// LibraryUninstall FIXMEDOC
2727
func LibraryUninstall(ctx context.Context, req *rpc.LibraryUninstallRequest, taskCB rpc.TaskProgressCB) error {
28-
lm := commands.GetLibraryManager(req.GetInstance().GetId())
28+
lm := commands.GetLibraryManager(req)
2929
ref, err := createLibIndexReference(lm, req)
3030
if err != nil {
3131
return &arduino.InvalidLibraryError{Cause: err}

0 commit comments

Comments
 (0)