Files
SideStore/AltStore/Operations/RemoveAppOperation.swift
naturecodevoid 0c171122b2 refactor minimuxer to use swift-bridge (#321)
also add team ID to the end of the bundle ID for Debug builds to mirror SideServer
2023-04-01 16:02:12 -07:00

58 lines
1.5 KiB
Swift

//
// RemoveAppOperation.swift
// AltStore
//
// Created by Riley Testut on 5/12/20.
// Copyright © 2020 Riley Testut. All rights reserved.
//
import Foundation
import AltStoreCore
import minimuxer
@objc(RemoveAppOperation)
final class RemoveAppOperation: ResultOperation<InstalledApp>
{
let context: InstallAppOperationContext
init(context: InstallAppOperationContext)
{
self.context = context
super.init()
}
override func main()
{
super.main()
if let error = self.context.error
{
self.finish(.failure(error))
return
}
guard let installedApp = self.context.installedApp else { return self.finish(.failure(OperationError.invalidParameters)) }
installedApp.managedObjectContext?.perform {
let resignedBundleIdentifier = installedApp.resignedBundleIdentifier
do {
try remove_app(resignedBundleIdentifier)
} catch {
return self.finish(.failure(minimuxerToOperationError(error)))
}
DatabaseManager.shared.persistentContainer.performBackgroundTask { (context) in
self.progress.completedUnitCount += 1
let installedApp = context.object(with: installedApp.objectID) as! InstalledApp
installedApp.isActive = false
self.finish(.success(installedApp))
}
}
}
}