Skip to content

Commit

Permalink
findLibraryIndexRelease requires libraries index instead of libraries…
Browse files Browse the repository at this point in the history
… manager
  • Loading branch information
cmaglie committed Dec 22, 2023
1 parent 9df2fd5 commit e9546fc
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion commands/lib/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func LibraryDownload(ctx context.Context, req *rpc.LibraryDownloadRequest, downl

logrus.Info("Preparing download")

lib, err := findLibraryIndexRelease(lm, req)
lib, err := findLibraryIndexRelease(lm.Index, req)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion commands/lib/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func LibraryInstall(ctx context.Context, req *rpc.LibraryInstallRequest, downloa
// Find the libReleasesToInstall to install
libReleasesToInstall := map[*librariesindex.Release]*librariesmanager.LibraryInstallPlan{}
for _, lib := range toInstall {
libRelease, err := findLibraryIndexRelease(lm, &rpc.LibraryInstallRequest{
libRelease, err := findLibraryIndexRelease(lm.Index, &rpc.LibraryInstallRequest{
Name: lib.GetName(),
Version: lib.GetVersionRequired(),
})
Expand Down
2 changes: 1 addition & 1 deletion commands/lib/resolve_deps.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func LibraryResolveDependencies(ctx context.Context, req *rpc.LibraryResolveDepe
}

// Search the requested lib
reqLibRelease, err := findLibraryIndexRelease(lm, req)
reqLibRelease, err := findLibraryIndexRelease(lm.Index, req)
if err != nil {
return nil, err
}
Expand Down
5 changes: 2 additions & 3 deletions commands/lib/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"github.com/arduino/arduino-cli/commands"
"github.com/arduino/arduino-cli/commands/cmderrors"
"github.com/arduino/arduino-cli/internal/arduino/libraries/librariesindex"
"github.com/arduino/arduino-cli/internal/arduino/libraries/librariesmanager"
)

type libraryReferencer interface {
Expand All @@ -36,12 +35,12 @@ func createLibIndexReference(req libraryReferencer) (*librariesindex.Reference,
return &librariesindex.Reference{Name: req.GetName(), Version: version}, nil
}

func findLibraryIndexRelease(lm *librariesmanager.LibrariesManager, req libraryReferencer) (*librariesindex.Release, error) {
func findLibraryIndexRelease(li *librariesindex.Index, req libraryReferencer) (*librariesindex.Release, error) {
ref, err := createLibIndexReference(req)
if err != nil {
return nil, err
}
lib := lm.Index.FindRelease(ref)
lib := li.FindRelease(ref)
if lib == nil {
return nil, &cmderrors.LibraryNotFoundError{Library: ref.String()}
}
Expand Down

0 comments on commit e9546fc

Please sign in to comment.