mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-19 03:33:36 +01:00
[removeExtensions]: Bug-Fix: appExtensions is not available later at async contect, so capture it prematurely when available
This commit is contained in:
@@ -1343,7 +1343,9 @@ private extension AppManager
|
|||||||
verifyOperation.addDependency(downloadOperation)
|
verifyOperation.addDependency(downloadOperation)
|
||||||
|
|
||||||
/* Remove App Extensions */
|
/* Remove App Extensions */
|
||||||
let removeAppExtensionsOperation = RemoveAppExtensionsOperation(context: context, appInDatabase: app)
|
let localAppExtensions = (app as? ALTApplication)?.appExtensions
|
||||||
|
let removeAppExtensionsOperation = RemoveAppExtensionsOperation(context: context,
|
||||||
|
localAppExtensions: localAppExtensions)
|
||||||
removeAppExtensionsOperation.resultHandler = { (result) in
|
removeAppExtensionsOperation.resultHandler = { (result) in
|
||||||
switch result
|
switch result
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,12 +16,12 @@ import AltSign
|
|||||||
final class RemoveAppExtensionsOperation: ResultOperation<Void>
|
final class RemoveAppExtensionsOperation: ResultOperation<Void>
|
||||||
{
|
{
|
||||||
let context: AppOperationContext
|
let context: AppOperationContext
|
||||||
let appInDatabase: AppProtocol
|
let localAppExtensions: Set<ALTApplication>?
|
||||||
|
|
||||||
init(context: AppOperationContext, appInDatabase: AppProtocol)
|
init(context: AppOperationContext, localAppExtensions: Set<ALTApplication>?)
|
||||||
{
|
{
|
||||||
self.context = context
|
self.context = context
|
||||||
self.appInDatabase = appInDatabase
|
self.localAppExtensions = localAppExtensions
|
||||||
super.init()
|
super.init()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,9 +41,8 @@ final class RemoveAppExtensionsOperation: ResultOperation<Void>
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
self.removeAppExtensions(from: targetAppBundle,
|
self.removeAppExtensions(from: targetAppBundle,
|
||||||
appInDatabase: appInDatabase as? ALTApplication,
|
localAppExtensions: localAppExtensions,
|
||||||
extensions: targetAppBundle.appExtensions,
|
extensions: targetAppBundle.appExtensions,
|
||||||
context.authenticatedContext.presentingViewController)
|
context.authenticatedContext.presentingViewController)
|
||||||
|
|
||||||
@@ -60,7 +59,7 @@ final class RemoveAppExtensionsOperation: ResultOperation<Void>
|
|||||||
|
|
||||||
|
|
||||||
private func removeAppExtensions(from targetAppBundle: ALTApplication,
|
private func removeAppExtensions(from targetAppBundle: ALTApplication,
|
||||||
appInDatabase: ALTApplication?,
|
localAppExtensions: Set<ALTApplication>?,
|
||||||
extensions: Set<ALTApplication>,
|
extensions: Set<ALTApplication>,
|
||||||
_ presentingViewController: UIViewController?)
|
_ presentingViewController: UIViewController?)
|
||||||
{
|
{
|
||||||
@@ -71,13 +70,13 @@ final class RemoveAppExtensionsOperation: ResultOperation<Void>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// process extensionsInfo
|
// process extensionsInfo
|
||||||
let excessExtensions = processExtensionsInfo(from: targetAppBundle, appInDatabase: appInDatabase)
|
let excessExtensions = processExtensionsInfo(from: targetAppBundle, localAppExtensions: localAppExtensions)
|
||||||
|
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
guard let presentingViewController: UIViewController = presentingViewController,
|
guard let presentingViewController: UIViewController = presentingViewController,
|
||||||
presentingViewController.viewIfLoaded?.window != nil else {
|
presentingViewController.viewIfLoaded?.window != nil else {
|
||||||
// background mode: remove only the excess extensions automatically for re-installs
|
// background mode: remove only the excess extensions automatically for re-installs
|
||||||
// keep all extensions for fresh install (appInDatabase = nil)
|
// keep all extensions for fresh install (localAppBundle = nil)
|
||||||
return self.backgroundModeExtensionsCleanup(excessExtensions: excessExtensions)
|
return self.backgroundModeExtensionsCleanup(excessExtensions: excessExtensions)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,13 +176,13 @@ final class RemoveAppExtensionsOperation: ResultOperation<Void>
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func processExtensionsInfo(from targetAppBundle: ALTApplication,
|
private func processExtensionsInfo(from targetAppBundle: ALTApplication,
|
||||||
appInDatabase: ALTApplication?) -> Set<ALTApplication>
|
localAppExtensions: Set<ALTApplication>?) -> Set<ALTApplication>
|
||||||
{
|
{
|
||||||
//App-Extensions: Ensure existing app's extensions in DB and currently installing app bundle's extensions must match
|
//App-Extensions: Ensure existing app's extensions in DB and currently installing app bundle's extensions must match
|
||||||
let targetAppEx: Set<ALTApplication> = targetAppBundle.appExtensions
|
let targetAppEx: Set<ALTApplication> = targetAppBundle.appExtensions
|
||||||
let targetAppExNames = targetAppEx.map{ appEx in appEx.bundleIdentifier}
|
let targetAppExNames = targetAppEx.map{ appEx in appEx.bundleIdentifier}
|
||||||
|
|
||||||
guard let extensionsInExistingApp = appInDatabase?.appExtensions else {
|
guard let extensionsInExistingApp = localAppExtensions else {
|
||||||
let diagnosticsMsg = "RemoveAppExtensionsOperation: ExistingApp is nil, Hence keeping all app extensions from targetAppBundle"
|
let diagnosticsMsg = "RemoveAppExtensionsOperation: ExistingApp is nil, Hence keeping all app extensions from targetAppBundle"
|
||||||
+ "RemoveAppExtensionsOperation: ExistingAppEx: nil; targetAppBundleEx: \(targetAppExNames)"
|
+ "RemoveAppExtensionsOperation: ExistingAppEx: nil; targetAppBundleEx: \(targetAppExNames)"
|
||||||
print(diagnosticsMsg)
|
print(diagnosticsMsg)
|
||||||
@@ -191,20 +190,15 @@ final class RemoveAppExtensionsOperation: ResultOperation<Void>
|
|||||||
}
|
}
|
||||||
|
|
||||||
let existingAppEx: Set<ALTApplication> = extensionsInExistingApp
|
let existingAppEx: Set<ALTApplication> = extensionsInExistingApp
|
||||||
|
|
||||||
let existingAppExNames = existingAppEx.map{ appEx in appEx.bundleIdentifier}
|
let existingAppExNames = existingAppEx.map{ appEx in appEx.bundleIdentifier}
|
||||||
|
|
||||||
let excessExtensionsInTargetApp = targetAppEx.filter{
|
let excessExtensionsInTargetApp = targetAppEx.filter{
|
||||||
!(existingAppExNames.contains($0.bundleIdentifier))
|
!(existingAppExNames.contains($0.bundleIdentifier))
|
||||||
}
|
}
|
||||||
|
|
||||||
let excessExtensionsInExistingApp = existingAppEx.filter{
|
|
||||||
!(targetAppExNames.contains($0.bundleIdentifier))
|
|
||||||
}
|
|
||||||
|
|
||||||
let isMatching = (targetAppEx.count == existingAppEx.count) && excessExtensionsInTargetApp.isEmpty
|
let isMatching = (targetAppEx.count == existingAppEx.count) && excessExtensionsInTargetApp.isEmpty
|
||||||
let diagnosticsMsg = "RemoveAppExtensionsOperation: App Extensions in existingApp and targetAppBundle are matching: \(isMatching)\n"
|
let diagnosticsMsg = "RemoveAppExtensionsOperation: App Extensions in localAppBundle and targetAppBundle are matching: \(isMatching)\n"
|
||||||
+ "RemoveAppExtensionsOperation: existingAppEx: \(existingAppExNames); targetAppBundleEx: \(String(describing: targetAppExNames))\n"
|
+ "RemoveAppExtensionsOperation: \nlocalAppBundleEx: \(existingAppExNames); \ntargetAppBundleEx: \(String(describing: targetAppExNames))\n"
|
||||||
print(diagnosticsMsg)
|
print(diagnosticsMsg)
|
||||||
|
|
||||||
return excessExtensionsInTargetApp
|
return excessExtensionsInTargetApp
|
||||||
|
|||||||
Reference in New Issue
Block a user