Check if can read pairing file before mounting

This commit is contained in:
Stossy11 2025-03-29 15:04:39 +11:00
parent e3de3d4ab3
commit c5011654a2

View file

@ -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