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:
parent
9de49dc313
commit
4386e35c59
|
@ -39,14 +39,10 @@ public class FileHelper {
|
||||||
public static OutputStream createFilepartOutputStream(final Path file) throws IOException {
|
public static OutputStream createFilepartOutputStream(final Path file) throws IOException {
|
||||||
final Path partFile = getPartFile(file);
|
final Path partFile = getPartFile(file);
|
||||||
FileHelper.createDirectories(partFile.getParent());
|
FileHelper.createDirectories(partFile.getParent());
|
||||||
|
|
||||||
OutputStream os = Files.newOutputStream(partFile, StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.CREATE);
|
OutputStream os = Files.newOutputStream(partFile, StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.CREATE);
|
||||||
return new WrappedOutputStream(os, () -> {
|
return new WrappedOutputStream(os, () -> {
|
||||||
if (!Files.exists(partFile)) return;
|
if (!Files.exists(partFile)) return;
|
||||||
|
|
||||||
Files.deleteIfExists(file);
|
|
||||||
FileHelper.createDirectories(file.getParent());
|
FileHelper.createDirectories(file.getParent());
|
||||||
|
|
||||||
FileHelper.move(partFile, file);
|
FileHelper.move(partFile, file);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue