aboutsummaryrefslogtreecommitdiff
path: root/src/github
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2013-12-11 21:23:51 -0800
committerScott Jackson <daneren2005@gmail.com>2013-12-11 21:23:51 -0800
commited2fafe67b27906923894b7422aedfe21a4868f6 (patch)
treef49bac197cbea06dedc09bf2be6f7a89baaebcae /src/github
parent629e0f03bbc1488d522e20aaefad1e50d0387e91 (diff)
downloaddsub-ed2fafe67b27906923894b7422aedfe21a4868f6.tar.gz
dsub-ed2fafe67b27906923894b7422aedfe21a4868f6.tar.bz2
dsub-ed2fafe67b27906923894b7422aedfe21a4868f6.zip
#215 Remove deleted playlists/podcasts from sync list
Diffstat (limited to 'src/github')
-rw-r--r--src/github/daneren2005/dsub/service/sync/PlaylistSyncAdapter.java8
-rw-r--r--src/github/daneren2005/dsub/service/sync/PodcastSyncAdapter.java6
-rw-r--r--src/github/daneren2005/dsub/util/SyncUtil.java15
3 files changed, 24 insertions, 5 deletions
diff --git a/src/github/daneren2005/dsub/service/sync/PlaylistSyncAdapter.java b/src/github/daneren2005/dsub/service/sync/PlaylistSyncAdapter.java
index dc754015..6e3b49c3 100644
--- a/src/github/daneren2005/dsub/service/sync/PlaylistSyncAdapter.java
+++ b/src/github/daneren2005/dsub/service/sync/PlaylistSyncAdapter.java
@@ -27,6 +27,7 @@ import java.util.List;
import github.daneren2005.dsub.domain.MusicDirectory;
import github.daneren2005.dsub.service.DownloadFile;
+import github.daneren2005.dsub.service.parser.SubsonicRESTException;
import github.daneren2005.dsub.util.SyncUtil;
import github.daneren2005.dsub.util.Util;
@@ -60,8 +61,13 @@ public class PlaylistSyncAdapter extends SubsonicSyncAdapter {
file.downloadNow(musicService);
}
}
+ } catch(SubsonicRESTException e) {
+ if(e.getCode() == 70) {
+ SyncUtil.removeSyncedPlaylist(context, id, instance);
+ Log.i(TAG, "Unsync deleted playlist " + id + " for " + serverName);
+ }
} catch(Exception e) {
- Log.e(TAG, "Failed to get playlist for " + serverName);
+ Log.e(TAG, "Failed to get playlist " + id + " for " + serverName);
}
}
}
diff --git a/src/github/daneren2005/dsub/service/sync/PodcastSyncAdapter.java b/src/github/daneren2005/dsub/service/sync/PodcastSyncAdapter.java
index f9311390..b5d39d72 100644
--- a/src/github/daneren2005/dsub/service/sync/PodcastSyncAdapter.java
+++ b/src/github/daneren2005/dsub/service/sync/PodcastSyncAdapter.java
@@ -30,6 +30,7 @@ import java.util.List;
import github.daneren2005.dsub.domain.MusicDirectory;
import github.daneren2005.dsub.domain.PodcastEpisode;
import github.daneren2005.dsub.service.DownloadFile;
+import github.daneren2005.dsub.service.parser.SubsonicRESTException;
import github.daneren2005.dsub.util.SyncUtil;
import github.daneren2005.dsub.util.SyncUtil.SyncSet;
import github.daneren2005.dsub.util.FileUtil;
@@ -84,6 +85,11 @@ public class PodcastSyncAdapter extends SubsonicSyncAdapter {
}
}
}
+ } catch(SubsonicRESTException e) {
+ if(e.getCode() == 70) {
+ SyncUtil.removeSyncedPodcast(context, id, instance);
+ Log.i(TAG, "Unsync deleted podcasts for " + id + " on " + Util.getServerName(context, instance));
+ }
} catch (Exception e) {
Log.w(TAG, "Failed to get podcasts for " + id + " on " + Util.getServerName(context, instance));
}
diff --git a/src/github/daneren2005/dsub/util/SyncUtil.java b/src/github/daneren2005/dsub/util/SyncUtil.java
index 4c5c0203..5a8b79f4 100644
--- a/src/github/daneren2005/dsub/util/SyncUtil.java
+++ b/src/github/daneren2005/dsub/util/SyncUtil.java
@@ -41,8 +41,12 @@ public final class SyncUtil {
syncedPlaylists = playlists;
}
public static void removeSyncedPlaylist(Context context, String playlistId) {
- String playlistFile = getPlaylistSyncFile(context);
- ArrayList<String> playlists = getSyncedPlaylists(context);
+ int instance = Util.getActiveServer(context);
+ removeSyncedPlaylist(context, playlistId, instance);
+ }
+ public static void removeSyncedPlaylist(Context context, String playlistId, int instance) {
+ String playlistFile = getPlaylistSyncFile(context, instance);
+ ArrayList<String> playlists = getSyncedPlaylists(context, instance);
if(playlists.contains(playlistId)) {
playlists.remove(playlistId);
FileUtil.serialize(context, playlists, playlistFile);
@@ -85,8 +89,11 @@ public final class SyncUtil {
syncedPodcasts = podcasts;
}
public static void removeSyncedPodcast(Context context, String podcastId) {
- String podcastFile = getPodcastSyncFile(context);
- ArrayList<SyncSet> podcasts = getSyncedPodcasts(context);
+ removeSyncedPodcast(context, podcastId, Util.getActiveServer(context));
+ }
+ public static void removeSyncedPodcast(Context context, String podcastId, int instance) {
+ String podcastFile = getPodcastSyncFile(context, instance);
+ ArrayList<SyncSet> podcasts = getSyncedPodcasts(context, instance);
SyncSet set = new SyncSet(podcastId);
if(podcasts.contains(set)) {
podcasts.remove(set);