1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-01-20 09:52:13 +01:00

Avoid usueless double calls to rescanLibraries()

Previously rescanLibraries() was automatically called internally in
setLibrariesFolder(). This lead to double calls to rescanLibraries()
when setLibrariesFolder() was used in combination with an explicit
call to rescanLibraries().

This commit adds a new method setLibrariesFoldersAndRescan(..) and
removes the internal call to rescanLibraries() from setLibrariesFolder().

The existing setLibrariesFolder()+rescanLibraries() combos have been
replaced with setLibrariesFoldersAndRescan().

Fix #10228
This commit is contained in:
Ricardo JL Rufino 2020-05-17 17:03:47 -03:00 committed by Cristian Maglie
parent cc65234582
commit b914070c90
2 changed files with 9 additions and 7 deletions

View File

@ -36,8 +36,7 @@ public class UpdatableLibraryTest {
LibrariesIndexer indexer = new LibrariesIndexer(index_SD_only);
BaseNoGui.librariesIndexer = indexer;
indexer.parseIndex();
indexer.setLibrariesFolders(folders);
indexer.rescanLibraries();
indexer.setLibrariesFoldersAndRescan(folders);
ContributedLibrary sdLib = indexer.getIndex().getInstalled("SD").get();
assertTrue("SD lib is installed", sdLib.isLibraryInstalled());
@ -46,7 +45,7 @@ public class UpdatableLibraryTest {
assertTrue(ContributionsSelfCheck.checkForUpdatableLibraries());
folders.add(new UserLibraryFolder(SD121, Location.SKETCHBOOK));
indexer.setLibrariesFolders(folders);
indexer.setLibrariesFoldersAndRescan(folders);
sdLib = indexer.getIndex().getInstalled("SD").get();
assertTrue("SD lib is installed", sdLib.isLibraryInstalled());
@ -63,8 +62,7 @@ public class UpdatableLibraryTest {
LibrariesIndexer indexer = new LibrariesIndexer(index_Bridge_only);
BaseNoGui.librariesIndexer = indexer;
indexer.parseIndex();
indexer.setLibrariesFolders(folders);
indexer.rescanLibraries();
indexer.setLibrariesFoldersAndRescan(folders);
ContributedLibrary l = indexer.getIndex().getInstalled("Bridge").get();
assertTrue("Bridge lib is installed", l.isLibraryInstalled());
@ -73,7 +71,7 @@ public class UpdatableLibraryTest {
assertTrue(ContributionsSelfCheck.checkForUpdatableLibraries());
folders.add(new UserLibraryFolder(Bridge170, Location.SKETCHBOOK));
indexer.setLibrariesFolders(folders);
indexer.setLibrariesFoldersAndRescan(folders);
l = indexer.getIndex().getInstalled("Bridge").get();
assertTrue("Bridge lib is installed", l.isLibraryInstalled());

View File

@ -114,7 +114,11 @@ public class LibrariesIndexer {
}
public void setLibrariesFolders(List<UserLibraryFolder> folders) {
librariesFolders = folders;
this.librariesFolders = folders;
}
public void setLibrariesFoldersAndRescan(List<UserLibraryFolder> folders) {
setLibrariesFolders(folders);
rescanLibraries();
}