Skip to content

Commit

Permalink
Fix condition when the file is not expire but the lastETag is changed
Browse files Browse the repository at this point in the history
  • Loading branch information
Mattia Bertorello authored and cmaglie committed Jul 23, 2019
1 parent b2235c3 commit dd1d713
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ private void downloadFile(boolean noResume) throws InterruptedException {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,17 +286,19 @@ public boolean isNotChange() {
@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
Expand Down

0 comments on commit dd1d713

Please sign in to comment.