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
7aecdbae
Unverified
Commit
7aecdbae
authored
Jul 22, 2019
by
Massimiliano Pippi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
report and catch a specific error when already installed
parent
32117466
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
4 deletions
+20
-4
arduino/libraries/librariesmanager/install.go
arduino/libraries/librariesmanager/install.go
+12
-3
commands/lib/install.go
commands/lib/install.go
+8
-1
No files found.
arduino/libraries/librariesmanager/install.go
View file @
7aecdbae
...
...
@@ -18,6 +18,7 @@
package
librariesmanager
import
(
"errors"
"fmt"
"github.com/arduino/arduino-cli/arduino/libraries"
...
...
@@ -26,18 +27,26 @@ import (
paths
"github.com/arduino/go-paths-helper"
)
var
(
// ErrAlreadyInstalled is returned when a library is already installed and task
// cannot proceed.
ErrAlreadyInstalled
=
errors
.
New
(
"library already installed"
)
)
// InstallPrerequisiteCheck performs prequisite checks to install a library. It returns the
// install path, where the library should be installed and the possible library that is already
// installed on the same folder and it's going to be replaced by the new one.
func
(
lm
*
LibrariesManager
)
InstallPrerequisiteCheck
(
indexLibrary
*
librariesindex
.
Release
)
(
*
paths
.
Path
,
*
libraries
.
Library
,
error
)
{
saneName
:=
utils
.
SanitizeName
(
indexLibrary
.
Library
.
Name
)
var
replaced
*
libraries
.
Library
if
installedLibs
,
have
:=
lm
.
Libraries
[
indexLibrary
.
Library
.
Name
];
have
{
if
installedLibs
,
have
:=
lm
.
Libraries
[
sane
Name
];
have
{
for
_
,
installedLib
:=
range
installedLibs
.
Alternatives
{
if
installedLib
.
Location
!=
libraries
.
Sketchbook
{
continue
}
if
installedLib
.
Version
.
Equal
(
indexLibrary
.
Version
)
{
return
installedLib
.
InstallDir
,
nil
,
fmt
.
Errorf
(
"%s is already installed"
,
indexLibrary
.
String
())
return
installedLib
.
InstallDir
,
nil
,
ErrAlreadyInstalled
}
replaced
=
installedLib
}
...
...
@@ -48,7 +57,7 @@ func (lm *LibrariesManager) InstallPrerequisiteCheck(indexLibrary *librariesinde
return
nil
,
nil
,
fmt
.
Errorf
(
"sketchbook directory not set"
)
}
libPath
:=
libsDir
.
Join
(
utils
.
SanitizeName
(
indexLibrary
.
Library
.
Name
)
)
libPath
:=
libsDir
.
Join
(
saneName
)
if
replaced
!=
nil
&&
replaced
.
InstallDir
.
EquivalentTo
(
libPath
)
{
}
else
if
libPath
.
IsDir
()
{
...
...
commands/lib/install.go
View file @
7aecdbae
...
...
@@ -58,16 +58,23 @@ func installLibrary(lm *librariesmanager.LibrariesManager, libRelease *libraries
taskCB
(
&
rpc
.
TaskProgress
{
Name
:
"Installing "
+
libRelease
.
String
()})
logrus
.
WithField
(
"library"
,
libRelease
)
.
Info
(
"Installing library"
)
libPath
,
libReplaced
,
err
:=
lm
.
InstallPrerequisiteCheck
(
libRelease
)
if
err
==
librariesmanager
.
ErrAlreadyInstalled
{
taskCB
(
&
rpc
.
TaskProgress
{
Message
:
"Alredy installed "
+
libRelease
.
String
(),
Completed
:
true
})
return
nil
}
if
err
!=
nil
{
return
fmt
.
Errorf
(
"checking lib install prerequisites: %s"
,
err
)
}
if
libReplaced
!=
nil
{
taskCB
(
&
rpc
.
TaskProgress
{
Message
:
fmt
.
Sprintf
(
"Replacing %s with %s"
,
libReplaced
,
libRelease
)})
}
if
err
:=
lm
.
Install
(
libRelease
,
libPath
);
err
!=
nil
{
return
err
}
taskCB
(
&
rpc
.
TaskProgress
{
Message
:
"Installed "
+
libRelease
.
String
(),
Completed
:
true
})
taskCB
(
&
rpc
.
TaskProgress
{
Message
:
"Installed "
+
libRelease
.
String
(),
Completed
:
true
})
return
nil
}
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