@@ -29,6 +29,7 @@ import (
29
29
"github.com/arduino/arduino-cli/arduino/utils"
30
30
paths "github.com/arduino/go-paths-helper"
31
31
"github.com/codeclysm/extract/v3"
32
+ semver "go.bug.st/relaxed-semver"
32
33
"gopkg.in/src-d/go-git.v4"
33
34
"gopkg.in/src-d/go-git.v4/plumbing"
34
35
)
48
49
// InstallPrerequisiteCheck performs prequisite checks to install a library. It returns the
49
50
// install path, where the library should be installed and the possible library that is already
50
51
// installed on the same folder and it's going to be replaced by the new one.
51
- func (lm * LibrariesManager ) InstallPrerequisiteCheck (indexLibrary * librariesindex. Release , installLocation libraries.LibraryLocation ) (* paths.Path , * libraries.Library , error ) {
52
+ func (lm * LibrariesManager ) InstallPrerequisiteCheck (name string , version * semver. Version , installLocation libraries.LibraryLocation ) (* paths.Path , * libraries.Library , error ) {
52
53
installDir := lm .getLibrariesDir (installLocation )
53
54
if installDir == nil {
54
55
if installLocation == libraries .User {
@@ -57,10 +58,9 @@ func (lm *LibrariesManager) InstallPrerequisiteCheck(indexLibrary *librariesinde
57
58
return nil , nil , fmt .Errorf (tr ("Builtin libraries directory not set" ))
58
59
}
59
60
60
- name := indexLibrary .Library .Name
61
61
libs := lm .FindByReference (& librariesindex.Reference {Name : name }, installLocation )
62
62
for _ , lib := range libs {
63
- if lib .Version != nil && lib .Version .Equal (indexLibrary . Version ) {
63
+ if lib .Version != nil && lib .Version .Equal (version ) {
64
64
return lib .InstallDir , nil , ErrAlreadyInstalled
65
65
}
66
66
}
@@ -82,7 +82,7 @@ func (lm *LibrariesManager) InstallPrerequisiteCheck(indexLibrary *librariesinde
82
82
replaced = libs [0 ]
83
83
}
84
84
85
- libPath := installDir .Join (utils .SanitizeName (indexLibrary . Library . Name ))
85
+ libPath := installDir .Join (utils .SanitizeName (name ))
86
86
if replaced != nil && replaced .InstallDir .EquivalentTo (libPath ) {
87
87
return libPath , replaced , nil
88
88
} else if libPath .IsDir () {
0 commit comments