Skip to content

Commit

Permalink
Complete disable cache if the file is not a *_indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
Mattia Bertorello committed Jul 12, 2019
1 parent 85e91ef commit 4da41f7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
8 changes: 2 additions & 6 deletions arduino-core/src/cc/arduino/utils/network/FileDownloader.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ private void downloadFile(boolean noResume) throws InterruptedException {
try {
setStatus(Status.CONNECTING);

final Optional<FileDownloaderCache.FileCached> fileCachedOpt = FileDownloaderCache.getFileCached(downloadUrl);
final Optional<FileDownloaderCache.FileCached> fileCachedOpt = FileDownloaderCache.getFileCached(downloadUrl, allowCache);
if (fileCachedOpt.isPresent()) {
final FileDownloaderCache.FileCached fileCached = fileCachedOpt.get();

Expand All @@ -175,11 +175,7 @@ private void downloadFile(boolean noResume) throws InterruptedException {
} else {
openConnectionAndFillTheFile(noResume);

if (allowCache) {
fileCached.updateCacheFile(outputFile);
} else {
log.info("The file {} was not cached because allow cache is false", downloadUrl);
}
fileCached.updateCacheFile(outputFile);
}
} else {
openConnectionAndFillTheFile(noResume);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,16 @@ public class FileDownloaderCache {
}

static Optional<FileCached> getFileCached(final URL remoteURL)
throws URISyntaxException, NoSuchMethodException, ScriptException,
IOException {
return getFileCached(remoteURL, true);
}

static Optional<FileCached> getFileCached(final URL remoteURL, boolean enableCache)
throws URISyntaxException, NoSuchMethodException, ScriptException,
IOException {
// Return always and empty file if the cache is not enable
if (!enableCache) {
if (!(enableCache && FileDownloaderCache.enableCache)) {
log.info("The cache is not enable.");
return Optional.empty();
}
Expand Down

0 comments on commit 4da41f7

Please sign in to comment.