Skip to content

Commit 6dadc4b

Browse files
committed
fix deleting temp files after download
1 parent 8dfd41b commit 6dadc4b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/main/java/lol/hyper/customlauncher/ttrupdater/TTRUpdater.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ public TTRUpdater(String title, Path installLocation) throws IOException {
295295
System.nanoTime() - startTime, TimeUnit.NANOSECONDS)
296296
+ " seconds.");
297297
}
298-
// delete the temp folder is there are files in there
298+
// delete all files in the temp folder
299299
File[] tempFolderFiles = tempFolder.listFiles();
300300
if (tempFolderFiles != null) {
301301
for (File currentFile : tempFolderFiles) {
@@ -316,6 +316,7 @@ public TTRUpdater(String title, Path installLocation) throws IOException {
316316
}
317317
}
318318
}
319+
// delete the actual temp folder
319320
try {
320321
Files.delete(Paths.get(System.getProperty("user.dir") + File.separator + "temp"));
321322
} catch (IOException e) {
@@ -373,10 +374,13 @@ public void decompressBz2(String temp, String outputName) throws IOException {
373374
out) {
374375
IOUtils.copy(in, out);
375376
}
377+
in.close();
378+
out.close();
376379
}
377380

378381
/**
379382
* Downloads TTR file and saves it to the temp folder.
383+
*
380384
* @param downloadURL The URL to download.
381385
* @param downloadOutput The file to save to.
382386
* @return True if successful, false if not.
@@ -405,6 +409,7 @@ public boolean saveFile(URL downloadURL, File downloadOutput) {
405409
count += n;
406410
progressBar.setValue((int) (count * 100 / imageEntity.getContentLength()));
407411
}
412+
output.close();
408413
} catch (IOException e) {
409414
isSucceed = false;
410415
}

0 commit comments

Comments
 (0)