Update GeneralUtils.java

This commit is contained in:
Ludy87 2025-07-30 21:10:24 +02:00
parent adb79e202e
commit ad72356d4f
No known key found for this signature in database
GPG Key ID: 92696155E0220F94

View File

@ -552,20 +552,23 @@ public class GeneralUtils {
e);
Files.move(tmp, target, StandardCopyOption.REPLACE_EXISTING);
}
} catch (FileAlreadyExistsException e) {
log.debug("File already exists at {}", target);
} catch (AccessDeniedException e) {
log.error("Access denied while attempting to copy resource to {}", target, e);
throw e;
} catch (FileSystemException e) {
log.debug(
"Failed to copy resource to {}: {}. Attempting to delete temporary file {}",
target,
e.getMessage(),
tmp);
try {
Files.deleteIfExists(tmp);
} catch (IOException ex) {
log.error("Failed to delete temporary file {}", tmp, ex);
}
log.error("File system error occurred while copying resource to {}", target, e);
throw e;
} catch (IOException e) {
log.error("Failed to copy resource to {}", target, e);
throw e;
} finally {
try {
Files.deleteIfExists(tmp);
} catch (IOException e) {
log.warn("Failed to delete temporary file {}", tmp, e);
}
}
}