aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2016-01-21 18:53:21 -0800
committerScott Jackson <daneren2005@gmail.com>2016-01-21 18:53:21 -0800
commit814d50293f6f40a8ba70a23506ad19454dbfb006 (patch)
tree1a5994c79257aac6c762419e9c348495566ca1dd /app
parentb40b55ab3dfb6dd77af541d5e6b56699a72405d1 (diff)
downloaddsub-814d50293f6f40a8ba70a23506ad19454dbfb006.tar.gz
dsub-814d50293f6f40a8ba70a23506ad19454dbfb006.tar.bz2
dsub-814d50293f6f40a8ba70a23506ad19454dbfb006.zip
Refresh Last.FM cache every couple of months (images expire and Subsonic updates periodically)
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/service/CachedMusicService.java17
1 files changed, 14 insertions, 3 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/service/CachedMusicService.java b/app/src/main/java/github/daneren2005/dsub/service/CachedMusicService.java
index d247f1fb..52268d82 100644
--- a/app/src/main/java/github/daneren2005/dsub/service/CachedMusicService.java
+++ b/app/src/main/java/github/daneren2005/dsub/service/CachedMusicService.java
@@ -72,6 +72,7 @@ public class CachedMusicService implements MusicService {
private static final int TTL_MUSIC_DIR = 5 * 60; // Five minutes
public static final int CACHE_UPDATE_LIST = 1;
public static final int CACHE_UPDATE_METADATA = 2;
+ private static final int CACHED_LAST_FM = 24 * 60;
private final RESTMusicService musicService;
private final TimeLimitedCache<Boolean> cachedLicenseValid = new TimeLimitedCache<Boolean>(120, TimeUnit.SECONDS);
@@ -1152,12 +1153,22 @@ public class CachedMusicService implements MusicService {
String cacheName = getCacheName(context, "artistInfo", id);
ArtistInfo info = null;
if(!refresh) {
- info = FileUtil.deserialize(context, cacheName, ArtistInfo.class);
+ info = FileUtil.deserialize(context, cacheName, ArtistInfo.class, CACHED_LAST_FM);
}
if(info == null && allowNetwork) {
- info = musicService.getArtistInfo(id, refresh, allowNetwork, context, progressListener);
- FileUtil.serialize(context, info, cacheName);
+ try {
+ info = musicService.getArtistInfo(id, refresh, allowNetwork, context, progressListener);
+ FileUtil.serialize(context, info, cacheName);
+ } catch(Exception e) {
+ Log.w(TAG, "Failed to refresh Artist Info");
+ info = FileUtil.deserialize(context, cacheName, ArtistInfo.class);
+
+ // Nothing ever cached, throw error further upstream
+ if(info == null) {
+ throw e;
+ }
+ }
}
return info;