Tentative fix trying to move a non-existing filepart file

This commit is contained in:
Blue (Lukas Rieger) 2021-09-13 23:05:47 +02:00
parent 8eb74004c6
commit 1d11206d13
No known key found for this signature in database
GPG Key ID: 904C4995F9E1F800

View File

@ -24,6 +24,8 @@
*/ */
package de.bluecolored.bluemap.core.util; package de.bluecolored.bluemap.core.util;
import de.bluecolored.bluemap.core.logger.Logger;
import java.io.*; import java.io.*;
import java.nio.file.*; import java.nio.file.*;
@ -39,6 +41,8 @@ public static OutputStream createFilepartOutputStream(final Path file) throws IO
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;
Files.deleteIfExists(file); Files.deleteIfExists(file);
Files.createDirectories(file.getParent()); Files.createDirectories(file.getParent());