1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-01-31 20:52:13 +01:00

Complete disable cache if the file is not a *_indexes

This commit is contained in:
Mattia Bertorello 2019-07-12 14:53:03 +02:00
parent 85e91ef079
commit 4da41f7fa5
No known key found for this signature in database
GPG Key ID: CE1FB2BE91770F24
2 changed files with 9 additions and 7 deletions

View File

@ -164,7 +164,7 @@ public class FileDownloader extends Observable {
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();
@ -175,11 +175,7 @@ public class FileDownloader extends Observable {
} 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);

View File

@ -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();
}