mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-13 00:33:28 +01:00
[AltServer] Ignores incompatible cached developer disks
Fixes issue where AltServer would always use cached developer disk, even if it isn’t compatible with the device’s operating system version.
This commit is contained in:
@@ -217,8 +217,17 @@ extension ALTDeviceManager
|
||||
ALTDeviceManager.shared.installDeveloperDiskImage(at: diskFileURL, signatureURL: signatureFileURL, to: device) { (success, error) in
|
||||
switch Result(success, error)
|
||||
{
|
||||
case .failure(let error): completionHandler(.failure(error))
|
||||
case .success: completionHandler(.success(()))
|
||||
case .failure(let error as ALTServerError) where error.code == .incompatibleDeveloperDisk:
|
||||
developerDiskManager.setDeveloperDiskCompatible(false, with: device)
|
||||
completionHandler(.failure(error))
|
||||
|
||||
case .failure(let error):
|
||||
// Don't mark developer disk as incompatible because it probably failed for a different reason.
|
||||
completionHandler(.failure(error))
|
||||
|
||||
case .success:
|
||||
developerDiskManager.setDeveloperDiskCompatible(true, with: device)
|
||||
completionHandler(.success(()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1204,7 +1204,38 @@ NSNotificationName const ALTDeviceManagerDeviceDidDisconnectNotification = @"ALT
|
||||
plist_free(result);
|
||||
}
|
||||
|
||||
finish(nil);
|
||||
// Verify the installed developer disk is compatible with altDevice's operating system version.
|
||||
ALTDebugConnection *testConnection = [[ALTDebugConnection alloc] initWithDevice:altDevice];
|
||||
[testConnection connectWithCompletionHandler:^(BOOL success, NSError * _Nullable error) {
|
||||
[testConnection disconnect];
|
||||
|
||||
if (success)
|
||||
{
|
||||
// Connection succeeded, so we assume the developer disk is compatible.
|
||||
finish(nil);
|
||||
}
|
||||
else if ([error.domain isEqualToString:AltServerConnectionErrorDomain] && error.code == ALTServerConnectionErrorUnknown)
|
||||
{
|
||||
// Connection failed with .unknown error code, so we assume the developer disk is NOT compatible.
|
||||
NSMutableDictionary *userInfo = [@{
|
||||
ALTOperatingSystemVersionErrorKey: NSStringFromOperatingSystemVersion(altDevice.osVersion),
|
||||
NSUnderlyingErrorKey: error,
|
||||
} mutableCopy];
|
||||
|
||||
NSString *osName = ALTOperatingSystemNameForDeviceType(altDevice.type);
|
||||
if (osName != nil)
|
||||
{
|
||||
userInfo[ALTOperatingSystemNameErrorKey] = osName;
|
||||
}
|
||||
|
||||
NSError *returnError = [NSError errorWithDomain:AltServerErrorDomain code:ALTServerErrorIncompatibleDeveloperDisk userInfo:userInfo];
|
||||
finish(returnError);
|
||||
}
|
||||
else
|
||||
{
|
||||
finish(error);
|
||||
}
|
||||
}];
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user