CORDA-2862: Fix to allow softlinks of logs directory (#5034)

This commit is contained in:
Manoj 2019-04-23 16:48:13 +08:00 committed by Shams Asari
parent f723f8c768
commit 87fe7b4d88

View File

@ -38,6 +38,7 @@ import java.io.RandomAccessFile
import java.lang.management.ManagementFactory
import java.net.InetAddress
import java.nio.channels.UnresolvedAddressException
import java.nio.file.Files
import java.nio.file.Path
import java.time.DayOfWeek
import java.time.ZonedDateTime
@ -486,7 +487,11 @@ fun CliWrapperBase.initLogging(baseDirectory: Path): Boolean {
//Test for access to the logging path and shutdown if we are unable to reach it.
val logPath = baseDirectory / NodeCliCommand.LOGS_DIRECTORY_NAME
try {
if (Files.isSymbolicLink(logPath)){
Files.readSymbolicLink(logPath).createDirectories()
} else {
logPath.createDirectories()
}
} catch (e: IOException) {
printError("Unable to create logging directory ${logPath.toString()}. Node will now shutdown.")
return false