Skip to content

Commit 4da41f7

Browse files
author
Mattia Bertorello
committed
Complete disable cache if the file is not a *_indexes
1 parent 85e91ef commit 4da41f7

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

Diff for: arduino-core/src/cc/arduino/utils/network/FileDownloader.java

+2-6
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ private void downloadFile(boolean noResume) throws InterruptedException {
164164
try {
165165
setStatus(Status.CONNECTING);
166166

167-
final Optional<FileDownloaderCache.FileCached> fileCachedOpt = FileDownloaderCache.getFileCached(downloadUrl);
167+
final Optional<FileDownloaderCache.FileCached> fileCachedOpt = FileDownloaderCache.getFileCached(downloadUrl, allowCache);
168168
if (fileCachedOpt.isPresent()) {
169169
final FileDownloaderCache.FileCached fileCached = fileCachedOpt.get();
170170

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

178-
if (allowCache) {
179-
fileCached.updateCacheFile(outputFile);
180-
} else {
181-
log.info("The file {} was not cached because allow cache is false", downloadUrl);
182-
}
178+
fileCached.updateCacheFile(outputFile);
183179
}
184180
} else {
185181
openConnectionAndFillTheFile(noResume);

Diff for: arduino-core/src/cc/arduino/utils/network/FileDownloaderCache.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,16 @@ public class FileDownloaderCache {
118118
}
119119

120120
static Optional<FileCached> getFileCached(final URL remoteURL)
121+
throws URISyntaxException, NoSuchMethodException, ScriptException,
122+
IOException {
123+
return getFileCached(remoteURL, true);
124+
}
125+
126+
static Optional<FileCached> getFileCached(final URL remoteURL, boolean enableCache)
121127
throws URISyntaxException, NoSuchMethodException, ScriptException,
122128
IOException {
123129
// Return always and empty file if the cache is not enable
124-
if (!enableCache) {
130+
if (!(enableCache && FileDownloaderCache.enableCache)) {
125131
log.info("The cache is not enable.");
126132
return Optional.empty();
127133
}

0 commit comments

Comments
 (0)