1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-02-07 01:54:26 +01:00

Use latest tools version for generic tool.paths properties

This commit is contained in:
Cristian Maglie 2016-08-02 14:11:12 +02:00
parent 6f24fa6cec
commit 3b57462281

View File

@ -5,6 +5,7 @@ import cc.arduino.Constants;
import cc.arduino.UploaderUtils; import cc.arduino.UploaderUtils;
import cc.arduino.contributions.GPGDetachedSignatureVerifier; import cc.arduino.contributions.GPGDetachedSignatureVerifier;
import cc.arduino.contributions.SignatureVerificationFailedException; import cc.arduino.contributions.SignatureVerificationFailedException;
import cc.arduino.contributions.VersionComparator;
import cc.arduino.contributions.libraries.LibrariesIndexer; import cc.arduino.contributions.libraries.LibrariesIndexer;
import cc.arduino.contributions.packages.ContributedPlatform; import cc.arduino.contributions.packages.ContributedPlatform;
import cc.arduino.contributions.packages.ContributedTool; import cc.arduino.contributions.packages.ContributedTool;
@ -866,6 +867,8 @@ public class BaseNoGui {
PreferencesData.removeAllKeysWithPrefix(prefix); PreferencesData.removeAllKeysWithPrefix(prefix);
} }
Map<String, String> latestVersions = new HashMap<>();
VersionComparator comparator = new VersionComparator();
for (ContributedTool tool : installedTools) { for (ContributedTool tool : installedTools) {
File installedFolder = tool.getDownloadableContribution(getPlatform()).getInstalledFolder(); File installedFolder = tool.getDownloadableContribution(getPlatform()).getInstalledFolder();
String toolPath; String toolPath;
@ -874,10 +877,15 @@ public class BaseNoGui {
} else { } else {
toolPath = Constants.PREF_REMOVE_PLACEHOLDER; toolPath = Constants.PREF_REMOVE_PLACEHOLDER;
} }
PreferencesData.set(prefix + tool.getName() + ".path", toolPath); String toolName = tool.getName();
PreferencesData.set(prefix + tool.getName() + "-" + tool.getVersion() + ".path", toolPath); String toolVersion = tool.getVersion();
PreferencesData.set(prefix + tool.getPackager() + "-" + tool.getName() + "-" + tool.getVersion() + ".path", PreferencesData.set(prefix + toolName + "-" + toolVersion + ".path", toolPath);
toolPath); PreferencesData.set(prefix + tool.getPackager() + "-" + toolName + "-" + toolVersion + ".path", toolPath);
// In the generic tool property put the path of the latest version if more are available
if (!latestVersions.containsKey(toolName) || comparator.greaterThan(toolVersion, latestVersions.get(toolName))) {
latestVersions.put(toolName, toolVersion);
PreferencesData.set(prefix + toolName + ".path", toolPath);
}
} }
} }