Skip to content

Commit ee86a8e

Browse files
authored
Improve installer version detection using semantic version sorting
This update replaces string-based version comparison with proper semantic version sorting using `packaging.version.Version`. This ensures that multiple Affinity installer builds are always detected and ordered correctly, even when version numbers include multi-digit components (e.g., 2.10.0 vs 2.9.1). As a result, affinity-cli now selects the most recent installer reliably, leading to more predictable and stable installation behavior—especially for users maintaining both v1 and v2 installers in the same directory. No breaking changes. This enhancement improves internal accuracy and overall user experience when managing multiple Affinity installer versions.
2 parents 52157a5 + 50148a0 commit ee86a8e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

affinity_cli/installer_discovery.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
from pathlib import Path
88
from typing import Dict, List, Literal, Optional
99

10+
from packaging.version import Version
11+
1012
PRODUCT_NAMES = {
1113
"photo": "Affinity Photo",
1214
"designer": "Affinity Designer",
@@ -59,7 +61,9 @@ def scan(self) -> List[InstallerInfo]:
5961
path=file,
6062
)
6163
)
62-
installers.sort(key=lambda item: (item.product, item.version, item.file_version))
64+
installers.sort(
65+
key=lambda item: (item.product, item.version, Version(item.file_version))
66+
)
6367
return installers
6468

6569
def select_installer(

0 commit comments

Comments
 (0)