Update app/common/src/main/java/stirling/software/common/util/GeneralUtils.java

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Ludy 2025-07-30 20:28:37 +02:00 committed by GitHub
parent 31d1ecae7d
commit fef607ec4a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -538,7 +538,12 @@ public class GeneralUtils {
Path tmp = Files.createTempFile(dir, target.getFileName().toString(), ".tmp");
try (InputStream in = resource.getInputStream()) {
Files.copy(in, tmp, StandardCopyOption.REPLACE_EXISTING);
Files.move(tmp, target, StandardCopyOption.ATOMIC_MOVE);
try {
Files.move(tmp, target, StandardCopyOption.ATOMIC_MOVE);
} catch (AtomicMoveNotSupportedException e) {
log.warn("Atomic move not supported, falling back to non-atomic move for {}", target, e);
Files.move(tmp, target, StandardCopyOption.REPLACE_EXISTING);
}
} catch (FileAlreadyExistsException e) {
log.debug("File already exists at {}", target);
try {