1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-12-01 12:24:14 +01:00

Remove temporary files when updating library_index.json

Fix #4272 #4332
This commit is contained in:
Cristian Maglie 2015-12-28 19:17:29 +01:00
parent a6e36fac9d
commit 29912a0ac9

View File

@ -53,8 +53,13 @@ public class GZippedJsonDownloader {
try {
new JsonDownloader(downloader, gzippedUrl).download(tmpFile, progress, statusText, progressListener);
File gzipTmpFile = new File(tmpFile.getParentFile(), GzipUtils.getCompressedFilename(tmpFile.getName()));
// remove eventual leftovers from previous downloads
if (gzipTmpFile.exists()) {
gzipTmpFile.delete();
}
tmpFile.renameTo(gzipTmpFile);
decompress(gzipTmpFile, tmpFile);
gzipTmpFile.delete();
} catch (Exception e) {
new JsonDownloader(downloader, url).download(tmpFile, progress, statusText, progressListener);
}