diff options
author | Scott Jackson <daneren2005@gmail.com> | 2014-03-21 23:21:10 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2014-03-21 23:21:10 -0700 |
commit | 89a25eb7653fc351c5519f35ca5e09c9ece53eea (patch) | |
tree | 7b905c8424c89a03c4b6bacb034a05f61b8f2375 | |
parent | 1aabeb57a59c7d0e8f88a939f3f1e987a296cd93 (diff) | |
download | dsub-89a25eb7653fc351c5519f35ca5e09c9ece53eea.tar.gz dsub-89a25eb7653fc351c5519f35ca5e09c9ece53eea.tar.bz2 dsub-89a25eb7653fc351c5519f35ca5e09c9ece53eea.zip |
Don't use sleepQuietly
-rw-r--r-- | src/github/daneren2005/dsub/service/DownloadFile.java | 29 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/service/RESTMusicService.java | 4 |
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); } } } |