From 1aabeb57a59c7d0e8f88a939f3f1e987a296cd93 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Fri, 21 Mar 2014 23:20:17 -0700 Subject: Better handling of 0 length songs --- src/github/daneren2005/dsub/service/DownloadFile.java | 4 +++- src/github/daneren2005/dsub/service/DownloadService.java | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/github/daneren2005/dsub/service/DownloadFile.java b/src/github/daneren2005/dsub/service/DownloadFile.java index 965a2a6f..fb0e50d0 100644 --- a/src/github/daneren2005/dsub/service/DownloadFile.java +++ b/src/github/daneren2005/dsub/service/DownloadFile.java @@ -398,6 +398,8 @@ public class DownloadFile implements BufferFile { if (isCancelled()) { throw new Exception("Download of '" + song + "' was cancelled"); + } else if(partialFile.length() == 0) { + throw new Exception("Download of '" + song + "' failed. File is 0 bytes long."); } downloadAndSaveCoverArt(musicService); @@ -449,7 +451,7 @@ public class DownloadFile implements BufferFile { } new CacheCleaner(context, DownloadService.getInstance()).cleanSpace(); if(DownloadService.getInstance() != null) { - ((DownloadService) DownloadService.getInstance()).checkDownloads(); + DownloadService.getInstance().checkDownloads(); } } diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java index 2d82e5fb..cb2fdcb2 100644 --- a/src/github/daneren2005/dsub/service/DownloadService.java +++ b/src/github/daneren2005/dsub/service/DownloadService.java @@ -1704,7 +1704,7 @@ public class DownloadService extends Service { while (!bufferComplete()) { Thread.sleep(1000L); - if (isCancelled()) { + if (isCancelled() || downloadFile.isFailedMax()) { return null; } } -- cgit v1.2.3