diff --git a/arduino-core/src/cc/arduino/utils/network/FileDownloader.java b/arduino-core/src/cc/arduino/utils/network/FileDownloader.java index 95138d8ff..b69a1fa1b 100644 --- a/arduino-core/src/cc/arduino/utils/network/FileDownloader.java +++ b/arduino-core/src/cc/arduino/utils/network/FileDownloader.java @@ -171,6 +171,7 @@ public class FileDownloader extends Observable { final Optional fileFromCache = getFileCached(fileCached); if (fileCached.isNotChange() && fileFromCache.isPresent()) { // Copy the cached file in the destination file + log.info("The file will be taken from the cache {}", fileFromCache); FileUtils.copyFile(fileFromCache.get(), outputFile); } else { openConnectionAndFillTheFile(noResume); diff --git a/arduino-core/src/cc/arduino/utils/network/FileDownloaderCache.java b/arduino-core/src/cc/arduino/utils/network/FileDownloaderCache.java index 4fe38689f..903f4ad24 100644 --- a/arduino-core/src/cc/arduino/utils/network/FileDownloaderCache.java +++ b/arduino-core/src/cc/arduino/utils/network/FileDownloaderCache.java @@ -286,17 +286,19 @@ public class FileDownloaderCache { @JsonIgnore public boolean isChange() { // Check if the file is expire - if (!isExpire()) { - log.debug("The file \"{}\" is no expire, the eTag will not be checked. Expire time: {}", localPath, + boolean isChange = false; + if (isExpire()) { + log.debug("The file \"{}\" is expire. Expire time: {}", localPath, this.getExpiresTime().format(DateTimeFormatter.ISO_DATE_TIME)); - return false; + isChange = true; } - if (lastETag != null) { + if (lastETag != null && !lastETag.equals(eTag)) { // If are different means that the file is change - return !lastETag.equals(eTag); + log.debug("The file \"{}\" is changed last ETag != now Etag ({}!={})", localPath, lastETag, eTag); + isChange = true; } - return true; + return isChange; } @JsonIgnore