fix(updates): parse version build suffix like 1.5.2-1

_parse_version split on "." only, so "2-1" hit int() and the whole
version collapsed to (0,) — update checks ignored build bumps and could
even offer a "downgrade". Extract every numeric run via regex instead:
"1.5.2-1" -> (1, 5, 2, 1).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-20 18:23:23 +05:00
parent efcefb5ae3
commit 11d2c06fb1

View File

@@ -2,6 +2,7 @@
Update Service - Check for updates and perform system updates
"""
import os
import re
import subprocess
import asyncio
import logging
@@ -182,11 +183,14 @@ def parse_repo_url(url: str) -> tuple:
def _parse_version(v: str) -> tuple:
"""Parse version string into a tuple of ints for comparison, e.g. '1.0.3' -> (1, 0, 3)"""
try:
return tuple(int(x) for x in v.strip().split("."))
except Exception:
return (0,)
"""Parse version string into a tuple of ints for comparison.
Handles a build suffix after '-': '1.5.2-1' -> (1, 5, 2, 1), '1.0.3' -> (1, 0, 3).
Splitting on '.' alone breaks on '2-1' (int() raises), collapsing the whole
version to (0,); extracting every numeric run keeps build bumps comparable.
"""
nums = re.findall(r"\d+", v.strip())
return tuple(int(x) for x in nums) if nums else (0,)
def _is_newer(remote: str, local: str) -> bool: