Redownloads missing cached apps when refreshing or updating

This commit is contained in:
Riley Testut
2020-05-08 11:43:34 -07:00
parent b4299c71fb
commit 76008022e7
3 changed files with 16 additions and 9 deletions

View File

@@ -498,8 +498,16 @@ private extension AppManager
group.beginInstallationHandler?(installedApp)
}
var downloadingApp = app
if let installedApp = app as? InstalledApp, let storeApp = installedApp.storeApp, !FileManager.default.fileExists(atPath: installedApp.fileURL.path)
{
// Cached app has been deleted, so we need to redownload it.
downloadingApp = storeApp
}
/* Download */
let downloadOperation = DownloadAppOperation(app: app, context: context)
let downloadOperation = DownloadAppOperation(app: downloadingApp, context: context)
downloadOperation.resultHandler = { (result) in
switch result
{
@@ -628,8 +636,9 @@ private extension AppManager
case .success(let installedApp):
completionHandler(.success(installedApp))
case .failure(ALTServerError.unknownRequest):
// Fall back to installation if AltServer doesn't support newer provisioning profile requests.
case .failure(ALTServerError.unknownRequest), .failure(OperationError.appNotFound):
// Fall back to installation if AltServer doesn't support newer provisioning profile requests,
// OR if the cached app could not be found and we may need to redownload it.
app.managedObjectContext?.performAndWait { // Must performAndWait to ensure we add operations before we return.
let installProgress = self._install(app, operation: operation, group: group) { (result) in
completionHandler(result)