1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-12-24 00:38:52 -05:00

Make sure there are no race conditions where etag is known but content just timed out thus resulting in a null response and no cached value to fall back on

This commit is contained in:
Reinhard Pointner 2016-04-12 07:31:26 +00:00
parent 580657aed0
commit eecd53a87d

View File

@ -300,9 +300,9 @@ public class TMDbClient implements MovieIdentificationService {
String cacheName = locale.getLanguage().isEmpty() ? getName() : getName() + "_" + locale;
Cache etagStorage = Cache.getCache(cacheName + "_etag", CacheType.Monthly);
Fetch fetchIfNoneMatch = fetchIfNoneMatch(url -> etagStorage.get(key), (url, etag) -> etagStorage.put(key, etag));
Cache cache = Cache.getCache(cacheName, CacheType.Monthly);
Fetch fetchIfNoneMatch = fetchIfNoneMatch(url -> cache.get(key) == null ? null : etagStorage.get(key), (url, etag) -> etagStorage.put(key, etag));
Object json = cache.json(key, s -> getResource(s, locale)).fetch(withPermit(fetchIfNoneMatch, r -> limit.acquirePermit())).expire(Cache.ONE_WEEK).get();
if (asMap(json).isEmpty()) {