Always delete temporary files on exit

This commit is contained in:
AsamK 2021-01-13 20:56:23 +01:00
parent 0624d6a808
commit 6bd857ad8b
2 changed files with 3 additions and 2 deletions

View file

@ -2141,7 +2141,6 @@ public class Manager implements Closeable {
GroupsV2Operations.GroupOperations groupOperations = groupsV2Operations.forGroup(groupSecretParams);
File tmpFile = IOUtils.createTempFile();
tmpFile.deleteOnExit();
try (InputStream input = messageReceiver.retrieveGroupsV2ProfileAvatar(cdnKey,
tmpFile,
ServiceConfig.AVATAR_DOWNLOAD_FAILSAFE_MAX_SIZE)) {

View file

@ -22,7 +22,9 @@ import static java.nio.file.attribute.PosixFilePermission.OWNER_WRITE;
public class IOUtils {
public static File createTempFile() throws IOException {
return File.createTempFile("signal_tmp_", ".tmp");
final File tempFile = File.createTempFile("signal-cli_tmp_", ".tmp");
tempFile.deleteOnExit();
return tempFile;
}
public static byte[] readFully(InputStream in) throws IOException {