mirror of
https://github.com/arduino/Arduino.git
synced 2024-11-29 10:24:12 +01:00
Fix condition when the file is not expire but the lastETag is changed
This commit is contained in:
parent
b2235c3a4a
commit
dd1d713d19
@ -171,6 +171,7 @@ public class FileDownloader extends Observable {
|
||||
final Optional<File> 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);
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user