[cleanup]: renamed new field for build revision from commitID to revision

This commit is contained in:
Magesh K
2024-12-18 02:32:11 +05:30
parent cf0a2001f0
commit 7af0992a2b
5 changed files with 22 additions and 16 deletions

View File

@@ -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

View File

@@ -62,12 +62,12 @@
<entity name="AppVersion" representedClassName="AppVersion" syncable="YES">
<attribute name="appBundleID" attributeType="String"/>
<attribute name="buildVersion" optional="YES" attributeType="String"/>
<attribute name="commitID" optional="YES" attributeType="String"/>
<attribute name="date" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="downloadURL" attributeType="URI"/>
<attribute name="localizedDescription" optional="YES" attributeType="String"/>
<attribute name="maxOSVersion" optional="YES" attributeType="String"/>
<attribute name="minOSVersion" optional="YES" attributeType="String"/>
<attribute name="revision" optional="YES" attributeType="String"/>
<attribute name="sha256" optional="YES" attributeType="String"/>
<attribute name="size" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
<attribute name="sourceID" optional="YES" attributeType="String"/>
@@ -243,7 +243,6 @@
<entity name="StoreApp" representedClassName="StoreApp" syncable="YES">
<attribute name="bundleIdentifier" attributeType="String"/>
<attribute name="category" optional="YES" attributeType="String"/>
<attribute name="commitID" optional="YES" attributeType="String"/>
<attribute name="developerName" attributeType="String"/>
<attribute name="downloadURL" attributeType="URI"/>
<attribute name="featuredSortID" optional="YES" attributeType="String"/>
@@ -258,6 +257,7 @@
<attribute name="pledgeAmount" optional="YES" attributeType="Decimal"/>
<attribute name="pledgeCurrency" optional="YES" attributeType="String"/>
<attribute name="prefersCustomPledge" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/>
<attribute name="revision" optional="YES" attributeType="String"/>
<attribute name="screenshotURLs" attributeType="Transformable" valueTransformerName="ALTSecureValueTransformer"/>
<attribute name="size" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
<attribute name="sortIndex" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>

View File

@@ -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
{

View File

@@ -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

View File

@@ -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)