diff --git a/AltStore/Operations/VerifyAppOperation.swift b/AltStore/Operations/VerifyAppOperation.swift index c63f0c69..ca44334d 100644 --- a/AltStore/Operations/VerifyAppOperation.swift +++ b/AltStore/Operations/VerifyAppOperation.swift @@ -129,6 +129,8 @@ private extension VerifyAppOperation { let (version, buildVersion) = await $appVersion.perform { ($0.version, $0.buildVersion) } + let downloadedIpaRevision = Bundle.init(url: app.fileURL)!.object(forInfoDictionaryKey: "BuildRevision") as? String ?? "" + guard version == app.version else { throw VerificationError.mismatchedVersion(app.version, expectedVersion: version, app: app) } if let buildVersion diff --git a/AltStoreCore/Model/AltStore.xcdatamodeld/AltStore 17.xcdatamodel/contents b/AltStoreCore/Model/AltStore.xcdatamodeld/AltStore 17.xcdatamodel/contents index 07e62ae5..65d011fe 100644 --- a/AltStoreCore/Model/AltStore.xcdatamodeld/AltStore 17.xcdatamodel/contents +++ b/AltStoreCore/Model/AltStore.xcdatamodeld/AltStore 17.xcdatamodel/contents @@ -62,12 +62,12 @@ - + @@ -243,7 +243,6 @@ - @@ -258,6 +257,7 @@ + diff --git a/AltStoreCore/Model/AppVersion.swift b/AltStoreCore/Model/AppVersion.swift index dc94c71b..74e5e6b2 100644 --- a/AltStoreCore/Model/AppVersion.swift +++ b/AltStoreCore/Model/AppVersion.swift @@ -46,8 +46,10 @@ public class AppVersion: NSManagedObject, Decodable, Fetchable @NSManaged public var appBundleID: String @NSManaged public var sourceID: String? + + // TODO: @mahee96: retire isBeta and use a string type to decode and store values as enum @NSManaged public var isBeta: Bool - @NSManaged public var commitID: String? + @NSManaged public var revision: String? /* Relationships */ @NSManaged public private(set) var app: StoreApp? @@ -70,7 +72,7 @@ public class AppVersion: NSManagedObject, Decodable, Fetchable case minOSVersion case maxOSVersion case isBeta - case commitID + case revision = "commitID" } public required init(from decoder: Decoder) throws @@ -97,7 +99,7 @@ public class AppVersion: NSManagedObject, Decodable, Fetchable self._maxOSVersion = try container.decodeIfPresent(String.self, forKey: .maxOSVersion) // self.isBeta = try container.decodeIfPresent(Bool.self, forKey: .isBeta) ?? false -// self.commitID = try container.decodeIfPresent(String.self, forKey: .commitID) +// self.revision = try container.decodeIfPresent(String.self, forKey: .revision) } catch { diff --git a/AltStoreCore/Model/InstalledApp.swift b/AltStoreCore/Model/InstalledApp.swift index 1a52f6c2..0aec8fdf 100644 --- a/AltStoreCore/Model/InstalledApp.swift +++ b/AltStoreCore/Model/InstalledApp.swift @@ -102,15 +102,15 @@ public class InstalledApp: NSManagedObject, InstalledAppProtocol // so it doesn't matter if semantic version was bumped, because commit ID won't be same // and we will accept this update - // storeApp.commitID is set in sources.json deployed at apps.json for the respective source - let commitID = storeApp.commitID ?? "" - if(isBeta && !commitID.isEmpty){ + // storeApp.revision is set in sources.json deployed at apps.json for the respective source + let revision = storeApp.revision ?? "" + if(isBeta && !revision.isEmpty){ let SHORT_COMMIT_LEN = 7 - let isCommitIDValid = (commitID.count == SHORT_COMMIT_LEN) - let installedAppCommitID = Bundle.main.object(forInfoDictionaryKey: "BuildRevision") as? String ?? "" - // when installing beta build over stable build installedAppCommitID will be empty! - let isBetaUpdateAvailable = (installedAppCommitID != commitID) - return isCommitIDValid && isBetaUpdateAvailable + let isRevisionValid = (revision.count == SHORT_COMMIT_LEN) + let installedAppRevision = Bundle.main.object(forInfoDictionaryKey: "BuildRevision") as? String ?? "" + // when installing beta build over stable build installedAppRevision will be empty! + let isBetaUpdateAvailable = (installedAppRevision != revision) + return isRevisionValid && isBetaUpdateAvailable } } return false diff --git a/AltStoreCore/Model/StoreApp.swift b/AltStoreCore/Model/StoreApp.swift index b24810e1..71ab779e 100644 --- a/AltStoreCore/Model/StoreApp.swift +++ b/AltStoreCore/Model/StoreApp.swift @@ -150,8 +150,10 @@ public class StoreApp: NSManagedObject, Decodable, Fetchable @NSManaged public private(set) var platformURLs: PlatformURLs? @NSManaged public private(set) var tintColor: UIColor? + + // TODO: @mahee96: retire isBeta and use a string type to decode and store values as enum @NSManaged public private(set) var isBeta: Bool - @NSManaged public private(set) var commitID: String? + @NSManaged public private(set) var revision: String? // Required for Marketplace apps. @NSManaged public private(set) var marketplaceID: String? @@ -290,7 +292,7 @@ public class StoreApp: NSManagedObject, Decodable, Fetchable case permissions = "appPermissions" case size case isBeta = "beta" - case commitID + case revision = "commitID" case versions case patreon case category @@ -322,7 +324,7 @@ public class StoreApp: NSManagedObject, Decodable, Fetchable self.subtitle = try container.decodeIfPresent(String.self, forKey: .subtitle) self.isBeta = try container.decodeIfPresent(Bool.self, forKey: .isBeta) ?? false - self.commitID = try container.decodeIfPresent(String.self, forKey: .commitID) + self.revision = try container.decodeIfPresent(String.self, forKey: .revision) var downloadURL = try container.decodeIfPresent(URL.self, forKey: .downloadURL) let platformURLs = try container.decodeIfPresent(PlatformURLs.self.self, forKey: .platformURLs)