Skip to content

Commit f1e4cbc

Browse files
committed
Fix backup for the 3rd time
1 parent 3020cee commit f1e4cbc

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

‎AltStore/Managing Apps/AppManager.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1398,7 +1398,7 @@ private extension AppManager
13981398
{
13991399
let progress = Progress.discreteProgress(totalUnitCount: 100)
14001400

1401-
let context = InstallAppOperationContext(bundleIdentifier: app.bundleIdentifier, authenticatedContext: group.context)
1401+
let context = context ?? InstallAppOperationContext(bundleIdentifier: app.bundleIdentifier, authenticatedContext: group.context)
14021402
context.customBundleIdentifier = customBundleIdentifier ?? (app as? InstalledApp)?.customBundleIdentifier
14031403
assert(context.authenticatedContext === group.context)
14041404

‎AltStore/Operations/InstallAppOperation.swift‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,16 @@ final class InstallAppOperation: ResultOperation<InstalledApp>, OperationLogging
2121

2222
let context: InstallAppOperationContext
2323
let storeApp: StoreApp?
24+
25+
// Keep returned InstalledApp objects attached until the result handler retains their context.
26+
private let managedObjectContext: NSManagedObjectContext
2427

2528
private var didCleanUp = false
2629

2730
init(context: InstallAppOperationContext, app: any AppProtocol) {
2831
self.context = context
2932
self.storeApp = app as? StoreApp
33+
self.managedObjectContext = DatabaseManager.shared.persistentContainer.newBackgroundContext()
3034

3135
super.init()
3236

@@ -62,9 +66,8 @@ final class InstallAppOperation: ResultOperation<InstalledApp>, OperationLogging
6266

6367
Task {
6468
do {
65-
let backgroundContext = DatabaseManager.shared.persistentContainer.newBackgroundContext()
6669
let installedApp = try await installApp(
67-
in: backgroundContext,
70+
in: managedObjectContext,
6871
certificate: certificate,
6972
resignedApp: resignedApp,
7073
provisioningProfiles: provisioningProfiles,

0 commit comments

Comments
 (0)