mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-09 06:43:25 +01:00
Redownloads missing cached apps when refreshing or updating
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -38,11 +38,12 @@ class FetchProvisioningProfilesOperation: ResultOperation<[String: ALTProvisioni
|
||||
}
|
||||
|
||||
guard
|
||||
let app = self.context.app,
|
||||
let team = self.context.team,
|
||||
let session = self.context.session
|
||||
else { return self.finish(.failure(OperationError.invalidParameters)) }
|
||||
|
||||
guard let app = self.context.app else { return self.finish(.failure(OperationError.appNotFound)) }
|
||||
|
||||
self.progress.totalUnitCount = Int64(1 + app.appExtensions.count)
|
||||
|
||||
self.prepareProvisioningProfile(for: app, parentApp: nil, team: team, session: session) { (result) in
|
||||
|
||||
@@ -40,12 +40,9 @@ class RefreshAppOperation: ResultOperation<InstalledApp>
|
||||
throw error
|
||||
}
|
||||
|
||||
guard
|
||||
let server = self.context.server,
|
||||
let app = self.context.app,
|
||||
let profiles = self.context.provisioningProfiles
|
||||
else { throw OperationError.invalidParameters }
|
||||
guard let server = self.context.server, let profiles = self.context.provisioningProfiles else { throw OperationError.invalidParameters }
|
||||
|
||||
guard let app = self.context.app else { throw OperationError.appNotFound }
|
||||
guard let udid = Bundle.main.object(forInfoDictionaryKey: Bundle.Info.deviceID) as? String else { throw OperationError.unknownUDID }
|
||||
|
||||
ServerManager.shared.connect(to: server) { (result) in
|
||||
|
||||
Reference in New Issue
Block a user