mirror of
https://github.com/arduino/Arduino.git
synced 2024-12-01 12:24:14 +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);
|
final Optional<File> fileFromCache = getFileCached(fileCached);
|
||||||
if (fileCached.isNotChange() && fileFromCache.isPresent()) {
|
if (fileCached.isNotChange() && fileFromCache.isPresent()) {
|
||||||
// Copy the cached file in the destination file
|
// Copy the cached file in the destination file
|
||||||
|
log.info("The file will be taken from the cache {}", fileFromCache);
|
||||||
FileUtils.copyFile(fileFromCache.get(), outputFile);
|
FileUtils.copyFile(fileFromCache.get(), outputFile);
|
||||||
} else {
|
} else {
|
||||||
openConnectionAndFillTheFile(noResume);
|
openConnectionAndFillTheFile(noResume);
|
||||||
|
@ -286,17 +286,19 @@ public class FileDownloaderCache {
|
|||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
public boolean isChange() {
|
public boolean isChange() {
|
||||||
// Check if the file is expire
|
// Check if the file is expire
|
||||||
if (!isExpire()) {
|
boolean isChange = false;
|
||||||
log.debug("The file \"{}\" is no expire, the eTag will not be checked. Expire time: {}", localPath,
|
if (isExpire()) {
|
||||||
|
log.debug("The file \"{}\" is expire. Expire time: {}", localPath,
|
||||||
this.getExpiresTime().format(DateTimeFormatter.ISO_DATE_TIME));
|
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
|
// 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
|
@JsonIgnore
|
||||||
|
Loading…
Reference in New Issue
Block a user