mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-09 06:43:25 +01:00
Add various retries to the minimuxer calls
This commit is contained in:
@@ -43,16 +43,21 @@ final class DeactivateAppOperation: ResultOperation<InstalledApp>
|
|||||||
let allIdentifiers = [installedApp.resignedBundleIdentifier] + appExtensionProfiles
|
let allIdentifiers = [installedApp.resignedBundleIdentifier] + appExtensionProfiles
|
||||||
|
|
||||||
for profile in allIdentifiers {
|
for profile in allIdentifiers {
|
||||||
do {
|
var attempts = 5
|
||||||
try remove_provisioning_profile(profile)
|
while (attempts != 0){
|
||||||
} catch {
|
print("Remove Provisioning profile attempts left: \(attempts)")
|
||||||
return self.finish(.failure(error))
|
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))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -204,17 +204,21 @@ final class InstallAppOperation: ResultOperation<InstalledApp>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var attempts = 10
|
||||||
do {
|
while (attempts != 0){
|
||||||
try install_ipa(installedApp.bundleIdentifier)
|
print("Install ipa attempts left: \(attempts)")
|
||||||
installing = false
|
do {
|
||||||
} catch {
|
try install_ipa(installedApp.bundleIdentifier)
|
||||||
installing = false
|
installing = false
|
||||||
return self.finish(.failure(error))
|
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))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,26 +35,27 @@ final class RefreshAppOperation: ResultOperation<InstalledApp>
|
|||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if let error = self.context.error
|
if let error = self.context.error { return self.finish(.failure(error)) }
|
||||||
{
|
|
||||||
throw error
|
|
||||||
}
|
|
||||||
|
|
||||||
guard let profiles = self.context.provisioningProfiles else { throw OperationError.invalidParameters }
|
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)) }
|
||||||
guard let app = self.context.app else { throw OperationError.appNotFound }
|
|
||||||
|
|
||||||
DatabaseManager.shared.persistentContainer.performBackgroundTask { (context) in
|
DatabaseManager.shared.persistentContainer.performBackgroundTask { (context) in
|
||||||
print("Sending refresh app request...")
|
print("Sending refresh app request...")
|
||||||
|
|
||||||
for p in profiles {
|
for p in profiles {
|
||||||
do {
|
var attempts = 5
|
||||||
let bytes = p.value.data.toRustByteSlice()
|
while (attempts != 0){
|
||||||
try install_provisioning_profile(bytes.forRust())
|
print("Install provisioning profile attempts left: \(attempts)")
|
||||||
} catch {
|
do {
|
||||||
return self.finish(.failure(error))
|
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
|
self.progress.completedUnitCount += 1
|
||||||
|
|
||||||
let predicate = NSPredicate(format: "%K == %@", #keyPath(InstalledApp.bundleIdentifier), app.bundleIdentifier)
|
let predicate = NSPredicate(format: "%K == %@", #keyPath(InstalledApp.bundleIdentifier), app.bundleIdentifier)
|
||||||
@@ -72,9 +73,5 @@ final class RefreshAppOperation: ResultOperation<InstalledApp>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
|
||||||
{
|
|
||||||
self.finish(.failure(error))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,8 +33,7 @@ final class SendAppOperation: ResultOperation<()>
|
|||||||
|
|
||||||
if let error = self.context.error
|
if let error = self.context.error
|
||||||
{
|
{
|
||||||
self.finish(.failure(error))
|
return self.finish(.failure(error))
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
guard let resignedApp = self.context.resignedApp else { return self.finish(.failure(OperationError.invalidParameters)) }
|
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)")
|
print("AFC App `fileURL`: \(fileURL.absoluteString)")
|
||||||
|
|
||||||
if let data = NSData(contentsOf: fileURL) {
|
if let data = NSData(contentsOf: fileURL) {
|
||||||
do {
|
var attempts = 10
|
||||||
let bytes = Data(data).toRustByteSlice()
|
while (attempts != 0){
|
||||||
try yeet_app_afc(app.bundleIdentifier, bytes.forRust())
|
print("Send app attempts left: \(attempts)")
|
||||||
} catch {
|
do {
|
||||||
return self.finish(.failure(error))
|
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 {
|
} else {
|
||||||
print("IPA doesn't exist????")
|
print("IPA doesn't exist????")
|
||||||
self.finish(.failure(ALTServerError(.underlyingError)))
|
return self.finish(.failure(ALTServerError(.underlyingError)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user