mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-20 14:54:31 +01:00
When resolving dependencies consider installed contributions first
Consider a case where the user decides to install a library `A` that depends on library `B` and `B` is not up-to-date (i.e. is installed a version that is not the latest), then the user is asked to "install" both libraries `A` and `B`, effectively upgrading `B`. With this change the already installed library `B` is left untouched and not displayed in the missing dependencies.
This commit is contained in:
parent
ed81292b14
commit
492553cde0
@ -138,13 +138,20 @@ public abstract class LibrariesIndex {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Pick the latest version among possible deps
|
||||
ContributedLibrary last = possibleDeps.stream()
|
||||
.reduce((a, b) -> b.isBefore(a) ? a : b).get();
|
||||
// Pick the installed version if available
|
||||
ContributedLibrary selected;
|
||||
Optional<ContributedLibrary> installed = possibleDeps.stream()
|
||||
.filter(l -> l.getInstalledLibrary().isPresent()).findAny();
|
||||
if (installed.isPresent()) {
|
||||
selected = installed.get();
|
||||
} else {
|
||||
// otherwise pick the latest version
|
||||
selected = possibleDeps.stream().reduce((a, b) -> b.isBefore(a) ? a : b).get();
|
||||
}
|
||||
|
||||
// Add dependecy to the solution and process recursively
|
||||
solution.add(last);
|
||||
if (!resolveDependeciesOf(solution, last)) {
|
||||
// Add dependency to the solution and process recursively
|
||||
solution.add(selected);
|
||||
if (!resolveDependeciesOf(solution, selected)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user