Improve exception handling in HttpDownloadHelper

This commit is contained in:
Simon Willnauer 2014-03-14 21:11:22 +01:00
parent d670575d74
commit b622fd18a2
1 changed files with 6 additions and 5 deletions

View File

@ -332,13 +332,14 @@ public class HttpDownloadHelper {
}
finished = !isInterrupted();
} finally {
IOUtils.close(os, is);
// we have started to (over)write dest, but failed.
// Try to delete the garbage we'd otherwise leave
// behind.
if (!finished) {
// we have started to (over)write dest, but failed.
// Try to delete the garbage we'd otherwise leave
// behind.
IOUtils.closeWhileHandlingException(os, is);
dest.delete();
} else {
IOUtils.close(os, is);
}
}
progress.endDownload();