diff options
author | daneren2005 <daneren2005@gmail.com> | 2014-04-29 15:58:22 -0700 |
---|---|---|
committer | daneren2005 <daneren2005@gmail.com> | 2014-04-29 15:58:22 -0700 |
commit | c388ae2b7b739f11e3e628d2e784004a53b56eea (patch) | |
tree | 4d550a13b1830f8c722d215b96fbbdfe29fae2f6 /src | |
parent | 8bf03270f032b966589c730acc2ff6b0db7a94e8 (diff) | |
download | dsub-c388ae2b7b739f11e3e628d2e784004a53b56eea.tar.gz dsub-c388ae2b7b739f11e3e628d2e784004a53b56eea.tar.bz2 dsub-c388ae2b7b739f11e3e628d2e784004a53b56eea.zip |
Don't retry when File can't be created
Fail limits don't apply to IOException because the most common failure is network issues. A FileOutputStream throws a FileNotFoundException when it can't write to a given file, so if that error is thrown the app can safely assume that the storage location is currently unavailable.
Diffstat (limited to 'src')
-rw-r--r-- | src/github/daneren2005/dsub/service/DownloadFile.java | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/github/daneren2005/dsub/service/DownloadFile.java b/src/github/daneren2005/dsub/service/DownloadFile.java index dc1c7cbd..e59e6f12 100644 --- a/src/github/daneren2005/dsub/service/DownloadFile.java +++ b/src/github/daneren2005/dsub/service/DownloadFile.java @@ -21,6 +21,7 @@ package github.daneren2005.dsub.service; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; +import java.io.FileNotFoundException; import java.io.InputStream; import java.io.OutputStream; @@ -434,8 +435,15 @@ public class DownloadFile implements BufferFile { } catch(InterruptedException x) { throw x; + } catch(FileNotFoundException x) { + Util.delete(completeFile); + Util.delete(saveFile); + if(!isCancelled()) { + failed = MAX_FAILURES + 1; + failedDownload = true; + Log.w(TAG, "Failed to download '" + song + "'.", x); + } } catch(IOException x) { - Util.close(out); Util.delete(completeFile); Util.delete(saveFile); if(!isCancelled()) { @@ -443,7 +451,6 @@ public class DownloadFile implements BufferFile { Log.w(TAG, "Failed to download '" + song + "'.", x); } } catch (Exception x) { - Util.close(out); Util.delete(completeFile); Util.delete(saveFile); if (!isCancelled()) { |