diff --git a/AltStore/Operations/DeactivateAppOperation.swift b/AltStore/Operations/DeactivateAppOperation.swift index 6feec196..f211a20e 100644 --- a/AltStore/Operations/DeactivateAppOperation.swift +++ b/AltStore/Operations/DeactivateAppOperation.swift @@ -43,16 +43,21 @@ final class DeactivateAppOperation: ResultOperation let allIdentifiers = [installedApp.resignedBundleIdentifier] + appExtensionProfiles for profile in allIdentifiers { - do { - try remove_provisioning_profile(profile) - } catch { - return self.finish(.failure(error)) + var attempts = 5 + while (attempts != 0){ + print("Remove Provisioning profile attempts left: \(attempts)") + do { + try remove_provisioning_profile(profile) + self.progress.completedUnitCount += 1 + installedApp.isActive = false + return self.finish(.success(installedApp)) + } catch { + if (attempts == 0){ + return self.finish(.failure(error)) + } else { attempts -= 1 } + } } } - - self.progress.completedUnitCount += 1 - installedApp.isActive = false - self.finish(.success(installedApp)) } } } diff --git a/AltStore/Operations/InstallAppOperation.swift b/AltStore/Operations/InstallAppOperation.swift index bc866498..793c0c85 100644 --- a/AltStore/Operations/InstallAppOperation.swift +++ b/AltStore/Operations/InstallAppOperation.swift @@ -204,17 +204,21 @@ final class InstallAppOperation: ResultOperation } } } - - do { - try install_ipa(installedApp.bundleIdentifier) - installing = false - } catch { - installing = false - return self.finish(.failure(error)) + var attempts = 10 + while (attempts != 0){ + print("Install ipa attempts left: \(attempts)") + do { + try install_ipa(installedApp.bundleIdentifier) + installing = false + installedApp.refreshedDate = Date() + return self.finish(.success(installedApp)) + } catch { + if (attempts == 0){ + installing = false + return self.finish(.failure(error)) + } else { attempts -= 1 } + } } - - installedApp.refreshedDate = Date() - self.finish(.success(installedApp)) } } diff --git a/AltStore/Operations/RefreshAppOperation.swift b/AltStore/Operations/RefreshAppOperation.swift index edf6a9e5..3c589c18 100644 --- a/AltStore/Operations/RefreshAppOperation.swift +++ b/AltStore/Operations/RefreshAppOperation.swift @@ -35,26 +35,27 @@ final class RefreshAppOperation: ResultOperation do { - if let error = self.context.error - { - throw error - } + if let error = self.context.error { return self.finish(.failure(error)) } - guard let profiles = self.context.provisioningProfiles else { throw OperationError.invalidParameters } - - guard let app = self.context.app else { throw OperationError.appNotFound } + guard let profiles = self.context.provisioningProfiles else { return self.finish(.failure(OperationError.invalidParameters)) } + guard let app = self.context.app else { return self.finish(.failure(OperationError.appNotFound)) } DatabaseManager.shared.persistentContainer.performBackgroundTask { (context) in print("Sending refresh app request...") for p in profiles { - do { - let bytes = p.value.data.toRustByteSlice() - try install_provisioning_profile(bytes.forRust()) - } catch { - return self.finish(.failure(error)) + var attempts = 5 + while (attempts != 0){ + print("Install provisioning profile attempts left: \(attempts)") + do { + let bytes = p.value.data.toRustByteSlice() + try install_provisioning_profile(bytes.forRust()) + } catch { + if (attempts == 0) { + return self.finish(.failure(error)) + } else { attempts -= 1 } + } } - self.progress.completedUnitCount += 1 let predicate = NSPredicate(format: "%K == %@", #keyPath(InstalledApp.bundleIdentifier), app.bundleIdentifier) @@ -72,9 +73,5 @@ final class RefreshAppOperation: ResultOperation } } } - catch - { - self.finish(.failure(error)) - } } } diff --git a/AltStore/Operations/SendAppOperation.swift b/AltStore/Operations/SendAppOperation.swift index afa5e57f..f7ddb242 100644 --- a/AltStore/Operations/SendAppOperation.swift +++ b/AltStore/Operations/SendAppOperation.swift @@ -33,8 +33,7 @@ final class SendAppOperation: ResultOperation<()> if let error = self.context.error { - self.finish(.failure(error)) - return + return self.finish(.failure(error)) } guard let resignedApp = self.context.resignedApp else { return self.finish(.failure(OperationError.invalidParameters)) } @@ -46,18 +45,24 @@ final class SendAppOperation: ResultOperation<()> print("AFC App `fileURL`: \(fileURL.absoluteString)") if let data = NSData(contentsOf: fileURL) { - do { - let bytes = Data(data).toRustByteSlice() - try yeet_app_afc(app.bundleIdentifier, bytes.forRust()) - } catch { - return self.finish(.failure(error)) + var attempts = 10 + while (attempts != 0){ + print("Send app attempts left: \(attempts)") + do { + let bytes = Data(data).toRustByteSlice() + try yeet_app_afc(app.bundleIdentifier, bytes.forRust()) + } catch { + attempts -= 1 + if (attempts == 0) { + return self.finish(.failure(error)) + } else { continue } + } + self.progress.completedUnitCount += 1 + return self.finish(.success(())) } - - self.progress.completedUnitCount += 1 - self.finish(.success(())) } else { print("IPA doesn't exist????") - self.finish(.failure(ALTServerError(.underlyingError))) + return self.finish(.failure(ALTServerError(.underlyingError))) } } }