aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/github/daneren2005/dsub/service/DownloadFile.java29
-rw-r--r--src/github/daneren2005/dsub/service/RESTMusicService.java4
2 files changed, 19 insertions, 14 deletions
diff --git a/src/github/daneren2005/dsub/service/DownloadFile.java b/src/github/daneren2005/dsub/service/DownloadFile.java
index fb0e50d0..8a0ec781 100644
--- a/src/github/daneren2005/dsub/service/DownloadFile.java
+++ b/src/github/daneren2005/dsub/service/DownloadFile.java
@@ -156,7 +156,11 @@ public class DownloadFile implements BufferFile {
public synchronized void downloadNow(MusicService musicService) {
preDownload();
downloadTask.setMusicService(musicService);
- downloadTask.doInBackground();
+ try {
+ downloadTask.doInBackground();
+ } catch(InterruptedException e) {
+ // This should never be reached
+ }
}
private void preDownload() {
FileUtil.createDirectoryForParent(saveFile);
@@ -327,8 +331,7 @@ public class DownloadFile implements BufferFile {
}
@Override
- public Void doInBackground() {
-
+ public Void doInBackground() throws InterruptedException {
InputStream in = null;
FileOutputStream out = null;
PowerManager.WakeLock wakeLock = null;
@@ -421,15 +424,17 @@ public class DownloadFile implements BufferFile {
}
} catch(SubsonicRESTException x) {
- Util.close(out);
- Util.delete(completeFile);
- Util.delete(saveFile);
- if (!isCancelled()) {
- failed++;
- failedDownload = true;
- Log.w(TAG, "Failed to download '" + song + "'.", x);
- }
- } catch (Exception x) {
+ Util.close(out);
+ Util.delete(completeFile);
+ Util.delete(saveFile);
+ if (!isCancelled()) {
+ failed++;
+ failedDownload = true;
+ Log.w(TAG, "Failed to download '" + song + "'.", x);
+ }
+ } catch(InterruptedException x) {
+ throw x;
+ } catch (Exception x) {
Util.close(out);
Util.delete(completeFile);
Util.delete(saveFile);
diff --git a/src/github/daneren2005/dsub/service/RESTMusicService.java b/src/github/daneren2005/dsub/service/RESTMusicService.java
index d08f0808..cd9f22d8 100644
--- a/src/github/daneren2005/dsub/service/RESTMusicService.java
+++ b/src/github/daneren2005/dsub/service/RESTMusicService.java
@@ -1351,7 +1351,7 @@ public class RESTMusicService implements MusicService {
private HttpResponse executeWithRetry(Context context, String url, String originalUrl, HttpParams requestParams,
List<String> parameterNames, List<Object> parameterValues,
- List<Header> headers, ProgressListener progressListener, SilentBackgroundTask task) throws IOException {
+ List<Header> headers, ProgressListener progressListener, SilentBackgroundTask task) throws Exception {
// Strip out sensitive information from log
Log.i(TAG, stripUrlInfo(url));
@@ -1424,7 +1424,7 @@ public class RESTMusicService implements MusicService {
}
Log.w(TAG, "Got IOException (" + attempts + "), will retry", x);
increaseTimeouts(requestParams);
- Util.sleepQuietly(2000L);
+ Thread.sleep(2000L);
}
}
}