diff --git a/Sources/GhosttyTerminalView.swift b/Sources/GhosttyTerminalView.swift index 60d201255b89..db1c8a8fb889 100644 --- a/Sources/GhosttyTerminalView.swift +++ b/Sources/GhosttyTerminalView.swift @@ -1634,9 +1634,9 @@ class GhosttyApp { let timestamp = ISO8601DateFormatter().string(from: Date()) let line = "[\(timestamp)] \(message)\n" if let handle = FileHandle(forWritingAtPath: initLogPath) { - handle.seekToEndOfFile() - handle.write(Data(line.utf8)) - handle.closeFile() + defer { try? handle.close() } + guard (try? handle.seekToEnd()) != nil else { return } + try? handle.write(contentsOf: Data(line.utf8)) } else { FileManager.default.createFile(atPath: initLogPath, contents: line.data(using: .utf8)) } @@ -3472,7 +3472,7 @@ class GhosttyApp { } if let handle = try? FileHandle(forWritingTo: backgroundLogURL) { defer { try? handle.close() } - try? handle.seekToEnd() + guard (try? handle.seekToEnd()) != nil else { return } try? handle.write(contentsOf: data) } } @@ -4141,9 +4141,9 @@ final class TerminalSurface: Identifiable, ObservableObject { let timestamp = ISO8601DateFormatter().string(from: Date()) let line = "[\(timestamp)] \(message)\n" if let handle = FileHandle(forWritingAtPath: surfaceLogPath) { - handle.seekToEndOfFile() - handle.write(Data(line.utf8)) - handle.closeFile() + defer { try? handle.close() } + guard (try? handle.seekToEnd()) != nil else { return } + try? handle.write(contentsOf: Data(line.utf8)) } else { FileManager.default.createFile(atPath: surfaceLogPath, contents: line.data(using: .utf8)) } @@ -4155,9 +4155,9 @@ final class TerminalSurface: Identifiable, ObservableObject { let timestamp = ISO8601DateFormatter().string(from: Date()) let line = "[\(timestamp)] \(message)\n" if let handle = FileHandle(forWritingAtPath: sizeLogPath) { - handle.seekToEndOfFile() - handle.write(Data(line.utf8)) - handle.closeFile() + defer { try? handle.close() } + guard (try? handle.seekToEnd()) != nil else { return } + try? handle.write(contentsOf: Data(line.utf8)) } else { FileManager.default.createFile(atPath: sizeLogPath, contents: line.data(using: .utf8)) } diff --git a/Sources/WorkspaceContentView.swift b/Sources/WorkspaceContentView.swift index 13b877817352..394b562938aa 100644 --- a/Sources/WorkspaceContentView.swift +++ b/Sources/WorkspaceContentView.swift @@ -695,9 +695,9 @@ extension WorkspaceContentView { let line = "[\(ts)] PANEL NOT FOUND for tabId=\(tab.id) ws=\(workspace.id) panelCount=\(workspace.panels.count)\n" let logPath = "/tmp/cmux-panel-debug.log" if let handle = FileHandle(forWritingAtPath: logPath) { - handle.seekToEndOfFile() - handle.write(Data(line.utf8)) - handle.closeFile() + defer { try? handle.close() } + guard (try? handle.seekToEnd()) != nil else { return } + try? handle.write(contentsOf: Data(line.utf8)) } else { FileManager.default.createFile(atPath: logPath, contents: line.data(using: .utf8)) } diff --git a/vendor/bonsplit b/vendor/bonsplit index 73bd9f9cfd8c..cffd9a66e9ed 160000 --- a/vendor/bonsplit +++ b/vendor/bonsplit @@ -1 +1 @@ -Subproject commit 73bd9f9cfd8c41ebc6f2d43eb48d3eafa4dfec00 +Subproject commit cffd9a66e9ede9aaedefcfd0c391f0ad49652d72