Add various retries to the minimuxer calls

This commit is contained in:
Nythepegasus
2023-07-11 01:44:11 -04:00
parent 59e537362e
commit dbdb4b0f32
4 changed files with 57 additions and 46 deletions

View File

@@ -35,26 +35,27 @@ final class RefreshAppOperation: ResultOperation<InstalledApp>
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<InstalledApp>
}
}
}
catch
{
self.finish(.failure(error))
}
}
}