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:
parent
85e91ef079
commit
4da41f7fa5
@ -164,7 +164,7 @@ public class FileDownloader extends Observable {
|
|||||||
try {
|
try {
|
||||||
setStatus(Status.CONNECTING);
|
setStatus(Status.CONNECTING);
|
||||||
|
|
||||||
final Optional<FileDownloaderCache.FileCached> fileCachedOpt = FileDownloaderCache.getFileCached(downloadUrl);
|
final Optional<FileDownloaderCache.FileCached> fileCachedOpt = FileDownloaderCache.getFileCached(downloadUrl, allowCache);
|
||||||
if (fileCachedOpt.isPresent()) {
|
if (fileCachedOpt.isPresent()) {
|
||||||
final FileDownloaderCache.FileCached fileCached = fileCachedOpt.get();
|
final FileDownloaderCache.FileCached fileCached = fileCachedOpt.get();
|
||||||
|
|
||||||
@ -175,11 +175,7 @@ public class FileDownloader extends Observable {
|
|||||||
} else {
|
} else {
|
||||||
openConnectionAndFillTheFile(noResume);
|
openConnectionAndFillTheFile(noResume);
|
||||||
|
|
||||||
if (allowCache) {
|
|
||||||
fileCached.updateCacheFile(outputFile);
|
fileCached.updateCacheFile(outputFile);
|
||||||
} else {
|
|
||||||
log.info("The file {} was not cached because allow cache is false", downloadUrl);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
openConnectionAndFillTheFile(noResume);
|
openConnectionAndFillTheFile(noResume);
|
||||||
|
@ -118,10 +118,16 @@ public class FileDownloaderCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Optional<FileCached> getFileCached(final URL remoteURL)
|
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,
|
throws URISyntaxException, NoSuchMethodException, ScriptException,
|
||||||
IOException {
|
IOException {
|
||||||
// Return always and empty file if the cache is not enable
|
// Return always and empty file if the cache is not enable
|
||||||
if (!enableCache) {
|
if (!(enableCache && FileDownloaderCache.enableCache)) {
|
||||||
log.info("The cache is not enable.");
|
log.info("The cache is not enable.");
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user