mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-09 06:43:25 +01:00
59 lines
1.5 KiB
Swift
59 lines
1.5 KiB
Swift
//
|
|
// DeactivateAppOperation.swift
|
|
// AltStore
|
|
//
|
|
// Created by Riley Testut on 3/4/20.
|
|
// Copyright © 2020 Riley Testut. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
import AltStoreCore
|
|
import AltSign
|
|
import Roxas
|
|
import minimuxer
|
|
|
|
@objc(DeactivateAppOperation)
|
|
final class DeactivateAppOperation: ResultOperation<InstalledApp>
|
|
{
|
|
let app: InstalledApp
|
|
let context: OperationContext
|
|
|
|
init(app: InstalledApp, context: OperationContext)
|
|
{
|
|
self.app = app
|
|
self.context = context
|
|
|
|
super.init()
|
|
}
|
|
|
|
override func main()
|
|
{
|
|
super.main()
|
|
|
|
if let error = self.context.error
|
|
{
|
|
self.finish(.failure(error))
|
|
return
|
|
}
|
|
|
|
DatabaseManager.shared.persistentContainer.performBackgroundTask { (context) in
|
|
let installedApp = context.object(with: self.app.objectID) as! InstalledApp
|
|
let appExtensionProfiles = installedApp.appExtensions.map { $0.resignedBundleIdentifier }
|
|
let allIdentifiers = [installedApp.resignedBundleIdentifier] + appExtensionProfiles
|
|
|
|
for profile in allIdentifiers {
|
|
do {
|
|
try remove_provisioning_profile(profile)
|
|
} catch {
|
|
return self.finish(.failure(minimuxerToOperationError(error)))
|
|
}
|
|
}
|
|
|
|
self.progress.completedUnitCount += 1
|
|
installedApp.isActive = false
|
|
self.finish(.success(installedApp))
|
|
}
|
|
}
|
|
}
|