Dont delete the file since we are replacing it anyways, to minimize the risk of deleting the file without a replacement

This commit is contained in:
Lukas Rieger (Blue) 2023-08-10 16:08:48 +02:00
parent 9de49dc313
commit 4386e35c59
No known key found for this signature in database
GPG Key ID: 2D09EC5ED2687FF2
1 changed files with 0 additions and 4 deletions

View File

@ -39,14 +39,10 @@ public class FileHelper {
public static OutputStream createFilepartOutputStream(final Path file) throws IOException {
final Path partFile = getPartFile(file);
FileHelper.createDirectories(partFile.getParent());
OutputStream os = Files.newOutputStream(partFile, StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.CREATE);
return new WrappedOutputStream(os, () -> {
if (!Files.exists(partFile)) return;
Files.deleteIfExists(file);
FileHelper.createDirectories(file.getParent());
FileHelper.move(partFile, file);
});
}