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
a58d5adb
Unverified
Commit
a58d5adb
authored
Jan 19, 2023
by
Luca Bianconi
Committed by
GitHub
Jan 19, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: scan libraries on install (#2037)
parent
18973684
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
73 additions
and
0 deletions
+73
-0
arduino/libraries/librariesmanager/install.go
arduino/libraries/librariesmanager/install.go
+1
-0
arduino/libraries/librariesmanager/librariesmanager.go
arduino/libraries/librariesmanager/librariesmanager.go
+7
-0
arduino/libraries/librariesmanager/librariesmanager_test.go
arduino/libraries/librariesmanager/librariesmanager_test.go
+32
-0
internal/integrationtest/daemon/daemon_test.go
internal/integrationtest/daemon/daemon_test.go
+33
-0
No files found.
arduino/libraries/librariesmanager/install.go
View file @
a58d5adb
...
...
@@ -64,6 +64,7 @@ func (lm *LibrariesManager) InstallPrerequisiteCheck(name string, version *semve
return
nil
,
err
}
lm
.
RescanLibraries
()
libs
:=
lm
.
FindByReference
(
&
librariesindex
.
Reference
{
Name
:
name
},
installLocation
)
if
len
(
libs
)
>
1
{
...
...
arduino/libraries/librariesmanager/librariesmanager.go
View file @
a58d5adb
...
...
@@ -132,6 +132,7 @@ func (lm *LibrariesManager) AddPlatformReleaseLibrariesDir(plaftormRelease *core
// RescanLibraries reload all installed libraries in the system.
func
(
lm
*
LibrariesManager
)
RescanLibraries
()
[]
*
status
.
Status
{
lm
.
clearLibraries
()
statuses
:=
[]
*
status
.
Status
{}
for
_
,
dir
:=
range
lm
.
LibrariesDir
{
if
errs
:=
lm
.
LoadLibrariesFromDir
(
dir
);
len
(
errs
)
>
0
{
...
...
@@ -217,3 +218,9 @@ func (lm *LibrariesManager) FindByReference(libRef *librariesindex.Reference, in
}
return
alternatives
.
FilterByVersionAndInstallLocation
(
libRef
.
Version
,
installLocation
)
}
func
(
lm
*
LibrariesManager
)
clearLibraries
()
{
for
k
:=
range
lm
.
Libraries
{
delete
(
lm
.
Libraries
,
k
)
}
}
arduino/libraries/librariesmanager/librariesmanager_test.go
0 → 100644
View file @
a58d5adb
// This file is part of arduino-cli.
//
// Copyright 2020 ARDUINO SA (http://www.arduino.cc/)
//
// This software is released under the GNU General Public License version 3,
// which covers the main part of arduino-cli.
// The terms of this license can be found at:
// https://www.gnu.org/licenses/gpl-3.0.en.html
//
// You can be released from the requirements of the above licenses by purchasing
// a commercial license. Buying such a license is mandatory if you want to
// modify or otherwise use the software for commercial activities involving the
// Arduino software without disclosing the source code of your own applications.
// To purchase a commercial license, send an email to license@arduino.cc.
package
librariesmanager
import
(
"testing"
"github.com/arduino/arduino-cli/arduino/libraries"
"github.com/arduino/go-paths-helper"
"github.com/stretchr/testify/require"
)
func
Test_RescanLibrariesCallClear
(
t
*
testing
.
T
)
{
baseDir
:=
paths
.
New
(
t
.
TempDir
())
lm
:=
NewLibraryManager
(
baseDir
.
Join
(
"index_dir"
),
baseDir
.
Join
(
"downloads_dir"
))
lm
.
Libraries
[
"testLibA"
]
=
libraries
.
List
{}
lm
.
Libraries
[
"testLibB"
]
=
libraries
.
List
{}
lm
.
RescanLibraries
()
require
.
Len
(
t
,
lm
.
Libraries
,
0
)
}
internal/integrationtest/daemon/daemon_test.go
View file @
a58d5adb
...
...
@@ -382,3 +382,36 @@ func TestDaemonBundleLibInstall(t *testing.T) {
}
}
}
func
TestDaemonLibrariesRescanOnInstall
(
t
*
testing
.
T
)
{
/*
Ensures that the libraries are rescanned prior to installing a new one,
to avoid clashes with libraries installed after the daemon initialization.
To perform the check:
- the daemon is run and a gprc instance initialized
- a library is installed through the cli
- an attempt to install a new version of the library is done
with the gprc instance
The last attempt is expected to not raise an error
*/
env
,
cli
:=
createEnvForDaemon
(
t
)
defer
env
.
CleanUp
()
grpcInst
:=
cli
.
Create
()
require
.
NoError
(
t
,
grpcInst
.
Init
(
""
,
""
,
func
(
ir
*
commands
.
InitResponse
)
{
fmt
.
Printf
(
"INIT> %v
\n
"
,
ir
.
GetMessage
())
}))
cli
.
Run
(
"lib"
,
"install"
,
"SD@1.2.3"
)
instCl
,
err
:=
grpcInst
.
LibraryInstall
(
context
.
Background
(),
"SD"
,
"1.2.4"
,
false
,
false
,
true
)
require
.
NoError
(
t
,
err
)
for
{
_
,
err
:=
instCl
.
Recv
()
if
err
==
io
.
EOF
{
break
}
require
.
NoError
(
t
,
err
)
}
}
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