mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-11 13:45:48 -04:00
fix[DownloadUtils]: When download fails, delete 0 byte file made by FileOutputSteam
This commit is contained in:
parent
df5e2067da
commit
c5e4d7e027
@ -61,6 +61,12 @@ public class DownloadUtils {
|
||||
FileUtils.ensureParentDirectory(out);
|
||||
try (FileOutputStream fileOutputStream = new FileOutputStream(out)) {
|
||||
download(url, fileOutputStream);
|
||||
} catch (IOException e) {
|
||||
if (out.length() < 1) { // Only delete it if file is 0 bytes cause this file might already be downloaded and something else went wrong.
|
||||
Log.i("DownloadUtils", "Cleaning up failed download: " + out.getAbsolutePath());
|
||||
out.delete();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user