mirror of
https://github.com/munki/munki.git
synced 2026-05-23 06:38:36 -05:00
Make sure log directory exists before attempting to create a missing log file. Addresses an issue with installhelper logging on a new install
This commit is contained in:
@@ -60,8 +60,12 @@ func munkiLog(_ message: String, logFile: String = "", logLevel: OSLogType = .de
|
||||
}
|
||||
}
|
||||
if let logData = logString.data(using: String.Encoding.utf8) {
|
||||
if !FileManager.default.fileExists(atPath: logPath) {
|
||||
FileManager.default.createFile(atPath: logPath, contents: nil)
|
||||
let fm = FileManager.default
|
||||
if !fm.fileExists(atPath: logPath) {
|
||||
if !pathIsDirectory(dirName(logPath), followSymlinks: true) {
|
||||
try? fm.createDirectory(atPath: dirName(logPath), withIntermediateDirectories: true)
|
||||
}
|
||||
fm.createFile(atPath: logPath, contents: nil)
|
||||
}
|
||||
if let fh = FileHandle(forUpdatingAtPath: logPath) {
|
||||
let _ = fh.seekToEndOfFile()
|
||||
|
||||
Reference in New Issue
Block a user