diff options
author | daneren2005 <daneren2005@gmail.com> | 2013-08-09 15:49:06 -0700 |
---|---|---|
committer | daneren2005 <daneren2005@gmail.com> | 2013-08-09 15:49:06 -0700 |
commit | d5286a60e905f64bb62f8e95633f5aaef8c13105 (patch) | |
tree | 8b4c9c41969522ce1ac9919bca9606e58900e7f2 /src | |
parent | 0ea6895860c9c8f721bae412cce353299a9ef3cc (diff) | |
download | dsub-d5286a60e905f64bb62f8e95633f5aaef8c13105.tar.gz dsub-d5286a60e905f64bb62f8e95633f5aaef8c13105.tar.bz2 dsub-d5286a60e905f64bb62f8e95633f5aaef8c13105.zip |
Fix forSong returning a dummy DownloadFile when not actively downloading
Diffstat (limited to 'src')
-rw-r--r-- | src/github/daneren2005/dsub/service/DownloadServiceImpl.java | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/github/daneren2005/dsub/service/DownloadServiceImpl.java b/src/github/daneren2005/dsub/service/DownloadServiceImpl.java index b555da99..85991abb 100644 --- a/src/github/daneren2005/dsub/service/DownloadServiceImpl.java +++ b/src/github/daneren2005/dsub/service/DownloadServiceImpl.java @@ -423,11 +423,16 @@ public class DownloadServiceImpl extends Service implements DownloadService { @Override public synchronized DownloadFile forSong(MusicDirectory.Entry song) { + DownloadFile returnFile = null; for (DownloadFile downloadFile : downloadList) { - if (downloadFile.getSong().equals(song) && - ((downloadFile.isDownloading() && !downloadFile.isDownloadCancelled() && downloadFile.getPartialFile().exists()) - || downloadFile.isWorkDone())) { - return downloadFile; + if (downloadFile.getSong().equals(song)) { + if(((downloadFile.isDownloading() && !downloadFile.isDownloadCancelled() && downloadFile.getPartialFile().exists()) || downloadFile.isWorkDone())) { + // If downloading, return immediately + return downloadFile; + } else { + // Otherwise, check to make sure there isn't a background download going on first + returnFile = downloadFile; + } } } for (DownloadFile downloadFile : backgroundDownloadList) { @@ -435,6 +440,10 @@ public class DownloadServiceImpl extends Service implements DownloadService { return downloadFile; } } + + if(returnFile != null) { + return returnFile; + } DownloadFile downloadFile = downloadFileCache.get(song); if (downloadFile == null) { |