From 7fc5fb868566e565d191555337840b15cbcb4081 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Wed, 15 Oct 2014 14:43:08 -0700 Subject: Fix issues with playlist file listings in offline mode In offline mode, playlists are read from a .m3u file which stores the absolute paths. No matter what, the files need to be passed to createEntry without the .complete part in the filename or else the files will not be found. If the normal name file does not exist, need to check against the .complete one as well before removing it from the list of valid songs to show in the playlist. --- .../daneren2005/dsub/service/OfflineMusicService.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/github/daneren2005/dsub/service/OfflineMusicService.java b/src/github/daneren2005/dsub/service/OfflineMusicService.java index 22b12cde..a676d9a1 100644 --- a/src/github/daneren2005/dsub/service/OfflineMusicService.java +++ b/src/github/daneren2005/dsub/service/OfflineMusicService.java @@ -428,12 +428,20 @@ public class OfflineMusicService implements MusicService { if(!"#EXTM3U".equals(line)) return playlist; while( (line = buffer.readLine()) != null ){ + // No matter what, end file can't have .complete in it + line = line.replace(".complete", ""); File entryFile = new File(line); - if(!entryFile.exists()) { - entryFile = new File(line.replace(".complete", "")); + + // Don't add file to playlist if it doesn't exist as cached or pinned! + File checkFile = entryFile; + if(!checkFile.exists()) { + // If normal file doens't exist, check if .complete version does + checkFile = new File(entryFile.getParent(), FileUtil.getBaseName(entryFile.getName()) + + ".complete" + FileUtil.getExtension(entryFile.getName())); } + String entryName = getName(entryFile); - if(entryFile.exists() && entryName != null){ + if(checkFile.exists() && entryName != null){ playlist.addChild(createEntry(context, entryFile, entryName, false)); } } -- cgit v1.2.3