mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-09 06:43:25 +01:00
[Beta-Updates]: Added beta update check feature
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="23507" systemVersion="24B91" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
|
||||
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="23605" systemVersion="24C101" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
|
||||
<entity name="Account" representedClassName="Account" syncable="YES">
|
||||
<attribute name="appleID" attributeType="String"/>
|
||||
<attribute name="firstName" attributeType="String"/>
|
||||
@@ -62,6 +62,7 @@
|
||||
<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"/>
|
||||
@@ -242,6 +243,7 @@
|
||||
<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"/>
|
||||
@@ -295,4 +297,4 @@
|
||||
</uniquenessConstraint>
|
||||
</uniquenessConstraints>
|
||||
</entity>
|
||||
</model>
|
||||
</model>
|
||||
@@ -47,6 +47,7 @@ public class AppVersion: NSManagedObject, Decodable, Fetchable
|
||||
@NSManaged public var appBundleID: String
|
||||
@NSManaged public var sourceID: String?
|
||||
@NSManaged public var isBeta: Bool
|
||||
@NSManaged public var commitID: String?
|
||||
|
||||
/* Relationships */
|
||||
@NSManaged public private(set) var app: StoreApp?
|
||||
@@ -69,6 +70,7 @@ public class AppVersion: NSManagedObject, Decodable, Fetchable
|
||||
case minOSVersion
|
||||
case maxOSVersion
|
||||
case isBeta
|
||||
case commitID
|
||||
}
|
||||
|
||||
public required init(from decoder: Decoder) throws
|
||||
@@ -91,9 +93,11 @@ public class AppVersion: NSManagedObject, Decodable, Fetchable
|
||||
self.size = try container.decode(Int64.self, forKey: .size)
|
||||
|
||||
self.sha256 = try container.decodeIfPresent(String.self, forKey: .sha256)?.lowercased()
|
||||
|
||||
self._minOSVersion = try container.decodeIfPresent(String.self, forKey: .minOSVersion)
|
||||
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)
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
@@ -77,18 +77,43 @@ public class InstalledApp: NSManagedObject, InstalledAppProtocol
|
||||
}
|
||||
|
||||
@objc public var hasUpdate: Bool {
|
||||
if self.storeApp == nil { return false }
|
||||
if self.storeApp!.latestSupportedVersion == nil { return false }
|
||||
guard let storeApp = self.storeApp,
|
||||
let latestSupportedVersion = storeApp.latestSupportedVersion?.version else {
|
||||
return false
|
||||
}
|
||||
|
||||
let currentVersion = SemanticVersion(self.version)
|
||||
let latestVersion = SemanticVersion(self.storeApp!.latestSupportedVersion!.version)
|
||||
let latestVersion = SemanticVersion(latestSupportedVersion)
|
||||
|
||||
if currentVersion == nil || latestVersion == nil {
|
||||
// One of the versions is not valid SemVer, fall back to comparing the version strings by character
|
||||
return self.version < self.storeApp!.latestSupportedVersion!.version
|
||||
return self.version < latestSupportedVersion
|
||||
}
|
||||
|
||||
return currentVersion! < latestVersion!
|
||||
let isBeta = storeApp.isBeta
|
||||
|
||||
// compare semantic version updates
|
||||
// - for stable releases "beta" shouldn't be true
|
||||
if !isBeta && (currentVersion! < latestVersion!) {
|
||||
return true
|
||||
}
|
||||
|
||||
if UserDefaults.standard.isBetaUpdatesEnabled {
|
||||
// NOTE: beta builds will always need commit ID suffix
|
||||
// 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){
|
||||
let SHORT_COMMIT_LEN = 7
|
||||
let isCommitIDValid = (commitID.count == SHORT_COMMIT_LEN)
|
||||
let installedAppCommitID = Bundle.main.object(forInfoDictionaryKey: kCFBundleVersionKey as String) as? String ?? ""
|
||||
// let isBetaUpdateAvailable = (installedAppCommitID.count == commitID.count) &&
|
||||
let isBetaUpdateAvailable = (installedAppCommitID != commitID)
|
||||
return isCommitIDValid && isBetaUpdateAvailable
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
public var appIDCount: Int {
|
||||
|
||||
@@ -151,6 +151,7 @@ public class StoreApp: NSManagedObject, Decodable, Fetchable
|
||||
|
||||
@NSManaged public private(set) var tintColor: UIColor?
|
||||
@NSManaged public private(set) var isBeta: Bool
|
||||
@NSManaged public private(set) var commitID: String?
|
||||
|
||||
// Required for Marketplace apps.
|
||||
@NSManaged public private(set) var marketplaceID: String?
|
||||
@@ -289,6 +290,7 @@ public class StoreApp: NSManagedObject, Decodable, Fetchable
|
||||
case permissions = "appPermissions"
|
||||
case size
|
||||
case isBeta = "beta"
|
||||
case commitID
|
||||
case versions
|
||||
case patreon
|
||||
case category
|
||||
@@ -311,6 +313,7 @@ public class StoreApp: NSManagedObject, Decodable, Fetchable
|
||||
do
|
||||
{
|
||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||
|
||||
self.name = try container.decode(String.self, forKey: .name)
|
||||
self.bundleIdentifier = try container.decode(String.self, forKey: .bundleIdentifier)
|
||||
self.developerName = try container.decode(String.self, forKey: .developerName)
|
||||
@@ -319,6 +322,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)
|
||||
|
||||
var downloadURL = try container.decodeIfPresent(URL.self, forKey: .downloadURL)
|
||||
let platformURLs = try container.decodeIfPresent(PlatformURLs.self.self, forKey: .platformURLs)
|
||||
|
||||
Reference in New Issue
Block a user