From e731fe026f87982473137f5baffd1387eb1003e7 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Thu, 11 Aug 2016 15:11:30 +0200 Subject: [PATCH] Boards Manager now install tools even if they are available in the IDE bundle Previously if a 3rd party core would require a tool already bundled in the IDE then boards manager skipped the installation of that tool. This is could lead to missing tools if the IDE is upgraded and the bundled tools may change. This patch fixes the bug by always installing tools when needed, even if they are already bundled. --- .../packages/ContributionInstaller.java | 15 +++++++-------- .../packages/ContributionsIndexer.java | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/arduino-core/src/cc/arduino/contributions/packages/ContributionInstaller.java b/arduino-core/src/cc/arduino/contributions/packages/ContributionInstaller.java index 28c3e0722..bbf9fab9f 100644 --- a/arduino-core/src/cc/arduino/contributions/packages/ContributionInstaller.java +++ b/arduino-core/src/cc/arduino/contributions/packages/ContributionInstaller.java @@ -79,16 +79,15 @@ public class ContributionInstaller { } // Do not download already installed tools - List tools = new LinkedList<>(contributedPlatform.getResolvedTools()); - Iterator toolsIterator = tools.iterator(); - while (toolsIterator.hasNext()) { - ContributedTool tool = toolsIterator.next(); + List tools = new ArrayList<>(); + for (ContributedTool tool : contributedPlatform.getResolvedTools()) { DownloadableContribution downloadable = tool.getDownloadableContribution(platform); if (downloadable == null) { throw new Exception(format(tr("Tool {0} is not available for your operating system."), tool.getName())); } - if (downloadable.isInstalled()) { - toolsIterator.remove(); + // Download the tool if it's not installed or it's a built-in tool + if (!downloadable.isInstalled() || downloadable.isReadOnly()) { + tools.add(tool); } } @@ -125,10 +124,10 @@ public class ContributionInstaller { List> resolvedToolReferences = contributedPlatform.getResolvedToolReferences().entrySet() .stream() - .filter((entry) -> !entry.getValue().getDownloadableContribution(platform).isInstalled()) + .filter((entry) -> !entry.getValue().getDownloadableContribution(platform).isInstalled() + || entry.getValue().getDownloadableContribution(platform).isReadOnly()) .collect(Collectors.toList()); - int i = 1; for (Map.Entry entry : resolvedToolReferences) { progress.setStatus(format(tr("Installing tools ({0}/{1})..."), i, resolvedToolReferences.size())); diff --git a/arduino-core/src/cc/arduino/contributions/packages/ContributionsIndexer.java b/arduino-core/src/cc/arduino/contributions/packages/ContributionsIndexer.java index 0e6d03794..e196d9b41 100644 --- a/arduino-core/src/cc/arduino/contributions/packages/ContributionsIndexer.java +++ b/arduino-core/src/cc/arduino/contributions/packages/ContributionsIndexer.java @@ -374,7 +374,7 @@ public class ContributionsIndexer { if (platformToIgnore.equals(platform)) { continue; } - if (!platform.isInstalled()) { + if (!platform.isInstalled() || platform.isReadOnly()) { continue; } for (ContributedTool requiredTool : platform.getResolvedTools()) {