Skip to content

Commit 60f19a8

Browse files
Avoid call rescanLibraries() twice #10228
1 parent fedad2f commit 60f19a8

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

Diff for: app/test/cc/arduino/contributions/UpdatableLibraryTest.java

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public void testUpdatableLibrary() throws Exception {
4747

4848
folders.add(new UserLibraryFolder(SD121, Location.SKETCHBOOK));
4949
indexer.setLibrariesFolders(folders);
50+
indexer.rescanLibraries();
5051

5152
sdLib = indexer.getIndex().getInstalled("SD").get();
5253
assertTrue("SD lib is installed", sdLib.isLibraryInstalled());
@@ -74,6 +75,7 @@ public void testUpdatableLibraryWithBundled() throws Exception {
7475

7576
folders.add(new UserLibraryFolder(Bridge170, Location.SKETCHBOOK));
7677
indexer.setLibrariesFolders(folders);
78+
indexer.rescanLibraries();
7779

7880
l = indexer.getIndex().getInstalled("Bridge").get();
7981
assertTrue("Bridge lib is installed", l.isLibraryInstalled());

Diff for: arduino-core/src/cc/arduino/contributions/libraries/LibrariesIndexer.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,13 @@ private void parseIndex(File file) throws IOException {
114114
}
115115

116116
public void setLibrariesFolders(List<UserLibraryFolder> folders) {
117-
librariesFolders = folders;
118-
rescanLibraries();
117+
setLibrariesFolders(folders, false);
119118
}
119+
120+
public void setLibrariesFolders(List<UserLibraryFolder> folders, boolean rescan) {
121+
librariesFolders = folders;
122+
if(rescan) rescanLibraries();
123+
}
120124

121125
public List<UserLibraryFolder> getLibrariesFolders() {
122126
return librariesFolders;

Diff for: arduino-core/src/processing/app/BaseNoGui.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -674,10 +674,11 @@ static public void onBoardOrPortChange() {
674674
// Scan for libraries in each library folder.
675675
// Libraries located in the latest folders on the list can override
676676
// other libraries with the same name.
677-
librariesIndexer.setLibrariesFolders(librariesFolders);
677+
librariesIndexer.setLibrariesFolders(librariesFolders, false);
678678
if (getTargetPlatform() != null) {
679679
librariesIndexer.setArchitecturePriority(getTargetPlatform().getId());
680680
}
681+
681682
librariesIndexer.rescanLibraries();
682683

683684
populateImportToLibraryTable();

0 commit comments

Comments
 (0)