Added convenience method to make the code more readable.

This commit is contained in:
CalDescent 2021-08-18 20:30:00 +01:00
parent 6375b9d14d
commit 11da1f72b1
2 changed files with 7 additions and 2 deletions

View File

@ -32,6 +32,10 @@ public class ArbitraryDataCache {
this.service = service;
}
public boolean isCachedDataAvailable() {
return !this.shouldInvalidate();
}
public boolean shouldInvalidate() {
try {
// If the user has requested an overwrite, always invalidate the cache

View File

@ -72,7 +72,7 @@ public class ArbitraryDataReader {
// Not in the build queue - so check the cache itself
ArbitraryDataCache cache = new ArbitraryDataCache(this.uncompressedPath, false,
this.resourceId, this.resourceIdType, this.service);
if (!cache.shouldInvalidate()) {
if (cache.isCachedDataAvailable()) {
this.filePath = this.uncompressedPath;
return true;
}
@ -111,7 +111,8 @@ public class ArbitraryDataReader {
try {
ArbitraryDataCache cache = new ArbitraryDataCache(this.uncompressedPath, overwrite,
this.resourceId, this.resourceIdType, this.service);
if (!cache.shouldInvalidate()) {
if (cache.isCachedDataAvailable()) {
// Use cached data
this.filePath = this.uncompressedPath;
return;
}