From c5011654a225cd1e5261b6fdee64916b9ea799dd Mon Sep 17 00:00:00 2001 From: Stossy11 <69031796+stossy11@users.noreply.github.com> Date: Sat, 29 Mar 2025 15:04:39 +1100 Subject: [PATCH] Check if can read pairing file before mounting --- StikJIT/StikJITApp.swift | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/StikJIT/StikJITApp.swift b/StikJIT/StikJITApp.swift index 40e8f5a..464b759 100644 --- a/StikJIT/StikJITApp.swift +++ b/StikJIT/StikJITApp.swift @@ -162,7 +162,6 @@ class MountingProgress: ObservableObject { } } - func pubMount() { mount() } private func mount() { @@ -171,7 +170,7 @@ class MountingProgress: ObservableObject { let fileManager = FileManager.default let pairingpath = URL.documentsDirectory.appendingPathComponent("pairingFile.plist").path - if fileManager.fileExists(atPath: pairingpath), !isMounted() { + if isPairing(), !isMounted() { if let mountingThread { mountingThread.cancel() self.mountingThread = nil @@ -200,6 +199,17 @@ class MountingProgress: ObservableObject { } } +func isPairing() -> Bool { + let pairingpath = URL.documentsDirectory.appendingPathComponent("pairingFile.plist").path + var pairingFile: IdevicePairingFile? + let err = idevice_pairing_file_read(pairingpath, &pairingFile) + if err != IdeviceSuccess { + print("Failed to read pairing file: \(err)") + return false + } + return true +} + func startHeartbeatInBackground() { let heartBeat = Thread { let completionHandler: @convention(block) (Int32, String?) -> Void = { result, message in