Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino-cli
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Operations
Operations
Metrics
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
arduino-cli
Commits
857caf2c
Commit
857caf2c
authored
Jul 20, 2018
by
Cristian Maglie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test if a library is already installed
Fix #111
parent
4234939e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
25 deletions
+17
-25
arduino/libraries/librariesmanager/install.go
arduino/libraries/librariesmanager/install.go
+11
-22
commands/commands_test.go
commands/commands_test.go
+5
-0
commands/lib/install.go
commands/lib/install.go
+1
-3
No files found.
arduino/libraries/librariesmanager/install.go
View file @
857caf2c
...
...
@@ -30,7 +30,6 @@
package
librariesmanager
import
(
"errors"
"fmt"
"os"
"path/filepath"
...
...
@@ -43,35 +42,25 @@ import (
)
// Install installs a library and returns the installed path.
func
Install
(
library
*
librariesindex
.
Release
)
(
string
,
error
)
{
if
library
==
nil
{
return
""
,
errors
.
New
(
"Not existing version of the library"
)
}
/*
installedRelease, err := library.InstalledRelease()
if err != nil {
return err
}
if installedRelease != nil {
//if installedRelease.Version != library.Latest().Version {
err := removeRelease(library.Name, installedRelease)
if err != nil {
return err
func
(
lm
*
LibrariesManager
)
Install
(
indexLibrary
*
librariesindex
.
Release
)
(
string
,
error
)
{
if
installedLibs
,
have
:=
lm
.
Libraries
[
indexLibrary
.
Library
.
Name
];
have
{
for
_
,
installedLib
:=
range
installedLibs
.
Alternatives
{
if
installedLib
.
Location
!=
libraries
.
Sketchbook
{
continue
}
if
installedLib
.
Version
==
indexLibrary
.
Version
{
return
installedLib
.
Folder
.
String
(),
fmt
.
Errorf
(
"%s is already installed"
,
indexLibrary
.
String
())
}
//} else {
// return nil // Already installed and latest version.
//}
}
*/
}
libsFolder
,
err
:=
configs
.
LibrariesFolder
.
Get
()
if
err
!=
nil
{
return
""
,
fmt
.
Errorf
(
"getting libraries directory: %s"
,
err
)
}
libPath
:=
filepath
.
Join
(
libsFolder
,
utils
.
SanitizeName
(
l
ibrary
.
Library
.
Name
))
return
libPath
,
l
ibrary
.
Resource
.
Install
(
libsFolder
,
libPath
)
libPath
:=
filepath
.
Join
(
libsFolder
,
utils
.
SanitizeName
(
indexL
ibrary
.
Library
.
Name
))
return
libPath
,
indexL
ibrary
.
Resource
.
Install
(
libsFolder
,
libPath
)
}
func
removeRelease
(
libName
string
,
r
*
libraries
.
Library
)
error
{
...
...
commands/commands_test.go
View file @
857caf2c
...
...
@@ -186,6 +186,11 @@ func TestLibDownloadAndInstall(t *testing.T) {
exitCode
,
d
=
executeWithArgs
(
t
,
"lib"
,
"list"
)
require
.
Zero
(
t
,
exitCode
,
"exit code"
)
require
.
Contains
(
t
,
string
(
d
),
"Audio"
)
exitCode
,
d
=
executeWithArgs
(
t
,
"lib"
,
"install"
,
"Audio"
)
require
.
NotZero
(
t
,
exitCode
,
"exit code"
)
require
.
Contains
(
t
,
string
(
d
),
"Audio@"
)
require
.
Contains
(
t
,
string
(
d
),
"already installed"
)
}
func
updateCoreIndex
(
t
*
testing
.
T
)
{
...
...
commands/lib/install.go
View file @
857caf2c
...
...
@@ -75,11 +75,9 @@ func installLibraries(lm *librariesmanager.LibrariesManager, refs []*librariesin
}
for
_
,
libRelease
:=
range
libReleasesToInstall
{
// FIXME: the library is installed again even if it's already installed
logrus
.
WithField
(
"library"
,
libRelease
)
.
Info
(
"Installing library"
)
if
_
,
err
:=
l
ibrariesmanager
.
Install
(
libRelease
);
err
!=
nil
{
if
_
,
err
:=
l
m
.
Install
(
libRelease
);
err
!=
nil
{
logrus
.
WithError
(
err
)
.
Warn
(
"Error installing library "
,
libRelease
)
formatter
.
PrintError
(
err
,
"Error installing library: "
+
libRelease
.
String
())
os
.
Exit
(
commands
.
ErrGeneric
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment