Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly handle versions with extension #207

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions OpenHaystack/OpenHaystack/HaystackApp/UpdateCheckController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,19 @@ public struct UpdateCheckController {
/// - installedVersion: The currently installed version
/// - Returns: .older when a newer version is available. .newer when the installed version is newer .same, if both versions are equal
internal static func compareVersions(availableVersion: String, installedVersion: String) -> VersionCompare {
let availableVersionSplit = availableVersion.split(separator: ".")
let installedVersionSplit = installedVersion.split(separator: ".")
// Handle dash extensions
var availableVersionTrim = availableVersion
var installedVersionTrim = installedVersion

if let dashIndex = availableVersion.firstIndex(of: "-") {
availableVersionTrim = String(availableVersion[..<dashIndex])
}
if let dashIndex = installedVersion.firstIndex(of: "-") {
installedVersionTrim = String(installedVersion[..<dashIndex])
}

let availableVersionSplit = availableVersionTrim.split(separator: ".")
let installedVersionSplit = installedVersionTrim.split(separator: ".")

for (idx, availableVersionPart) in availableVersionSplit.enumerated() {

Expand Down