Skip to content

Commit b1f9164

Browse files
committed
Slightly refactored ContributionsIndexer.syncBuiltInHardware()
This is just a small rewrite of the function in a more clear way, no change in behavior.
1 parent e80c085 commit b1f9164

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

arduino-core/src/cc/arduino/contributions/packages/ContributionsIndexer.java

+22-14
Original file line numberDiff line numberDiff line change
@@ -212,20 +212,28 @@ private void syncBuiltInHardware() throws IOException {
212212
}
213213
for (File folder : builtInHardwareFolder.listFiles(ONLY_DIRS)) {
214214
ContributedPackage pack = index.findPackage(folder.getName());
215-
if (pack != null) {
216-
syncBuiltInPackageWithFilesystem(pack, folder);
217-
218-
File toolsFolder = new File(builtInHardwareFolder, "tools");
219-
if (toolsFolder.isDirectory()) {
220-
for (File toolFolder : toolsFolder.listFiles(ONLY_DIRS)) {
221-
File builtInToolsMetadata = new File(toolFolder, "builtin_tools_versions.txt");
222-
if (builtInToolsMetadata.isFile()) {
223-
PreferencesMap toolsMetadata = new PreferencesMap(builtInToolsMetadata).subTree(pack.getName());
224-
for (Map.Entry<String, String> toolMetadata : toolsMetadata.entrySet()) {
225-
syncToolWithFilesystem(pack, toolFolder, toolMetadata.getKey(), toolMetadata.getValue());
226-
}
227-
}
228-
}
215+
if (pack == null)
216+
continue;
217+
syncBuiltInPackageWithFilesystem(pack, folder);
218+
219+
File toolsFolder = new File(builtInHardwareFolder, "tools");
220+
if (!toolsFolder.isDirectory())
221+
continue;
222+
223+
for (File toolFolder : toolsFolder.listFiles(ONLY_DIRS)) {
224+
225+
// builtin_tools_versions.txt contains tools versions in the format:
226+
// "PACKAGER.TOOL_NAME=TOOL_VERSION"
227+
// for example:
228+
// "arduino.avrdude=6.0.1-arduino5"
229+
230+
File versionsFile = new File(toolFolder, "builtin_tools_versions.txt");
231+
if (!versionsFile.isFile())
232+
continue;
233+
PreferencesMap toolsVersion = new PreferencesMap(versionsFile).subTree(pack.getName());
234+
for (String name : toolsVersion.keySet()) {
235+
String version = toolsVersion.get(name);
236+
syncToolWithFilesystem(pack, toolFolder, name, version);
229237
}
230238
}
231239
}

0 commit comments

Comments
 (0)