1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-03-13 10:29:35 +01:00

Add comments

This commit is contained in:
Mattia Bertorello 2019-07-04 18:14:06 +02:00
parent ba79e26cbc
commit 53695d49d8
No known key found for this signature in database
GPG Key ID: CE1FB2BE91770F24

View File

@ -173,8 +173,10 @@ public class FileDownloaderCache {
if (cachedFiles != null) {
synchronized (cachedFiles) {
ObjectMapper mapper = new ObjectMapper();
// Generate a pretty json
mapper.enable(SerializationFeature.INDENT_OUTPUT);
final ObjectNode objectNode = mapper.createObjectNode();
// Generate a json {"files":[...{files_info}...]}
objectNode.putArray("files").addAll(
cachedFiles.values().stream()
.map((v) -> mapper.convertValue(v, JsonNode.class))
@ -184,6 +186,7 @@ public class FileDownloaderCache {
if (Files.notExists(cachedFileInfo)) {
Files.createDirectories(cachedFileInfo.getParent());
}
// Write to cache.json
mapper.writeValue(cachedFileInfo.toFile(), objectNode);
}
}