Verifies downloaded app’s version matches source

This commit is contained in:
Riley Testut
2023-05-11 17:47:03 -05:00
parent 10ac6507ec
commit 244a1de2ca
2 changed files with 21 additions and 0 deletions

View File

@@ -58,7 +58,9 @@ class VerifyAppOperation: ResultOperation<Void>
do
{
guard let ipaURL = self.context.ipaURL else { throw OperationError.appNotFound(name: app.name) }
try await self.verifyHash(of: app, at: ipaURL, matches: appVersion)
try await self.verifyDownloadedVersion(of: app, matches: appVersion)
self.finish(.success(()))
}
@@ -90,4 +92,11 @@ private extension VerifyAppOperation
guard hashString == expectedHash else { throw VerificationError.mismatchedHash(hashString, expectedHash: expectedHash, app: app) }
}
func verifyDownloadedVersion(of app: ALTApplication, @AsyncManaged matches appVersion: AppVersion) async throws
{
let version = await $appVersion.version
guard version == app.version else { throw VerificationError.mismatchedVersion(app.version, expectedVersion: version, app: app) }
}
}