mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-21 15:54:39 +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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pick the latest version among possible deps
|
// Pick the installed version if available
|
||||||
ContributedLibrary last = possibleDeps.stream()
|
ContributedLibrary selected;
|
||||||
.reduce((a, b) -> b.isBefore(a) ? a : b).get();
|
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
|
// Add dependency to the solution and process recursively
|
||||||
solution.add(last);
|
solution.add(selected);
|
||||||
if (!resolveDependeciesOf(solution, last)) {
|
if (!resolveDependeciesOf(solution, selected)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user