1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-01-19 08:52:15 +01:00

Print error if library.index is not parsed. Update index only after successful parsing.

This commit is contained in:
Cristian Maglie 2017-12-14 19:29:34 +01:00
parent b832e0d8b1
commit cd3639a574

View File

@ -89,12 +89,16 @@ public class LibrariesIndexer {
mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
mapper.configure(DeserializationFeature.EAGER_DESERIALIZER_FETCH, true);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
index = mapper.readValue(indexIn, LibrariesIndex.class);
LibrariesIndex newIndex = mapper.readValue(indexIn, LibrariesIndex.class);
index.getLibraries()
newIndex.getLibraries()
.stream()
.filter(library -> library.getCategory() == null || "".equals(library.getCategory()) || !Constants.LIBRARY_CATEGORIES.contains(library.getCategory()))
.forEach(library -> library.setCategory("Uncategorized"));
index = newIndex;
} catch (Exception e) {
System.err.println("Error parsing library.index:" + e.getMessage());
} finally {
IOUtils.closeQuietly(indexIn);
}