fix(apple/macOS): Move to .idle state after log export (#8091)

This fixes a bug where we couldn't export logs twice because we never
returned to the `.idle` state after export.

Fixes #8015
This commit is contained in:
Jamil
2025-02-10 23:07:27 -08:00
committed by GitHub
parent 6c93ce76bf
commit 41f4ae5e7f
2 changed files with 8 additions and 3 deletions

View File

@@ -251,7 +251,12 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
func exportLogs(_ completionHandler: @escaping (Data?) -> Void) {
func sendChunk(_ tunnelLogArchive: TunnelLogArchive) {
do {
let chunk = try tunnelLogArchive.readChunk()
let (chunk, done) = try tunnelLogArchive.readChunk()
if done {
self.logExportState = .idle
}
completionHandler(chunk)
} catch {
Log.error(error)

View File

@@ -65,7 +65,7 @@ class TunnelLogArchive {
)
}
func readChunk() throws -> Data {
func readChunk() throws -> (Data, Bool) {
if self.fileHandle == nil {
// Open the file for reading
try self.fileHandle = FileHandle(forReadingFrom: archiveURL)
@@ -94,7 +94,7 @@ class TunnelLogArchive {
cleanup()
}
return try encoder.encode(chunk)
return try (encoder.encode(chunk), chunk.done)
}
func cleanup() {