mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Clean up temporary file if tarTo raises an exception
This commit is contained in:
parent
ddc524b588
commit
513e83fa00
1 changed files with 6 additions and 0 deletions
|
@ -42,6 +42,9 @@ public class Tar {
|
|||
/* Closes target */
|
||||
try (OutputStream bzip2 = new BZip2CompressorOutputStream(target)) {
|
||||
tarTo(fileOrDir, bzip2);
|
||||
} catch (IOException e) {
|
||||
tmp.delete();
|
||||
throw e;
|
||||
}
|
||||
if (sizePtr != null) {
|
||||
sizePtr[0] = tmp.length();
|
||||
|
@ -69,6 +72,9 @@ public class Tar {
|
|||
try (FileOutputStream target = new FileOutputStream(tmp)) {
|
||||
tarTo(fileOrDir, target);
|
||||
return new DeletingFileInputStream(tmp);
|
||||
} catch (IOException e) {
|
||||
tmp.delete();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue