Refactors app version comparison logic to always include buildVersion

Before, whether or not the source included the buildVersion affected the comparison. If present, the buildVersion was used in comparison, if not, only the version itself was used for comparsion.

This meant it was impossible to update from a version with a buildVersion to the same version without one (e.g. going from betas to final releases). Now we _always_ consider the buildVersion in the comparsion, so an earlier entry in versions array without buildVersion can be considered “newer” even if versions match.
This commit is contained in:
Riley Testut
2023-05-26 19:12:13 -05:00
committed by Magesh K
parent 641e7d5f2e
commit 7f9ee81150
4 changed files with 35 additions and 20 deletions

View File

@@ -47,6 +47,9 @@ final class InstallAppOperation: ResultOperation<InstalledApp>
return self.finish(.failure(OperationError.invalidParameters("InstallAppOperation.main: self.context.certificate or self.context.resignedApp or self.context.provisioningProfiles is nil")))
}
@Managed var appVersion = self.context.appVersion
let storeBuildVersion = $appVersion.buildVersion
let backgroundContext = DatabaseManager.shared.persistentContainer.newBackgroundContext()
backgroundContext.perform {
@@ -61,10 +64,14 @@ final class InstallAppOperation: ResultOperation<InstalledApp>
}
else
{
installedApp = InstalledApp(resignedApp: resignedApp, originalBundleIdentifier: self.context.bundleIdentifier, certificateSerialNumber: certificate.serialNumber, context: backgroundContext)
installedApp = InstalledApp(resignedApp: resignedApp,
originalBundleIdentifier: self.context.bundleIdentifier,
certificateSerialNumber: certificate.serialNumber,
storeBuildVersion: storeBuildVersion,
context: backgroundContext)
}
installedApp.update(resignedApp: resignedApp, certificateSerialNumber: certificate.serialNumber)
installedApp.update(resignedApp: resignedApp, certificateSerialNumber: certificate.serialNumber, storeBuildVersion: storeBuildVersion)
installedApp.needsResign = false
if let team = DatabaseManager.shared.activeTeam(in: backgroundContext)