mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-12 14:16:58 -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);
|
FileUtils.ensureParentDirectory(out);
|
||||||
try (FileOutputStream fileOutputStream = new FileOutputStream(out)) {
|
try (FileOutputStream fileOutputStream = new FileOutputStream(out)) {
|
||||||
download(url, fileOutputStream);
|
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