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.lang.management.ManagementFactory
import java.net.InetAddress import java.net.InetAddress
import java.nio.channels.UnresolvedAddressException import java.nio.channels.UnresolvedAddressException
import java.nio.file.Files
import java.nio.file.Path import java.nio.file.Path
import java.time.DayOfWeek import java.time.DayOfWeek
import java.time.ZonedDateTime 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. //Test for access to the logging path and shutdown if we are unable to reach it.
val logPath = baseDirectory / NodeCliCommand.LOGS_DIRECTORY_NAME val logPath = baseDirectory / NodeCliCommand.LOGS_DIRECTORY_NAME
try { try {
logPath.createDirectories() if (Files.isSymbolicLink(logPath)){
Files.readSymbolicLink(logPath).createDirectories()
} else {
logPath.createDirectories()
}
} catch (e: IOException) { } catch (e: IOException) {
printError("Unable to create logging directory ${logPath.toString()}. Node will now shutdown.") printError("Unable to create logging directory ${logPath.toString()}. Node will now shutdown.")
return false return false