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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user