Release resources before trying to delete an incomplete file #264 #211

This commit is contained in:
len
2016-04-19 21:04:28 +02:00
parent a9bfeb058b
commit 19bf47b6d2
2 changed files with 9 additions and 4 deletions

View File

@@ -56,12 +56,12 @@ public final class DiskUtils {
try {
bufferedSink = Okio.buffer(Okio.sink(writeFile));
bufferedSink.writeAll(bufferedSource);
Util.closeQuietly(bufferedSink);
} catch (Exception e) {
Util.closeQuietly(bufferedSink);
//noinspection ResultOfMethodCallIgnored
writeFile.delete();
throw new IOException("Unable to save image");
} finally {
Util.closeQuietly(bufferedSink);
Util.closeQuietly(bufferedSource);
}
return writeFile;
@@ -74,6 +74,7 @@ public final class DiskUtils {
}
}
//noinspection ResultOfMethodCallIgnored
inputFile.delete();
}