A Python port of the Invisible Internet Project (I2P)
1"""Update checker — checks for available router updates.
2
3Compares the current router version against available updates
4and determines if an update is needed.
5
6Ported from net.i2p.update.UpdateHandler / UpdateManager.
7"""
8
9from __future__ import annotations
10
11from dataclasses import dataclass
12
13from i2p_apps.updater.version import compare_versions
14
15
16@dataclass
17class UpdateInfo:
18 """Information about an available update."""
19 version: str
20 url: str
21 sig_url: str = ""
22 min_version: str = ""
23
24
25class UpdateChecker:
26 """Checks whether the router needs updating."""
27
28 def __init__(self, current_version: str) -> None:
29 self.current_version = current_version
30
31 def needs_update(self, info: UpdateInfo) -> bool:
32 """Check if an update is needed based on version comparison."""
33 return compare_versions(info.version, self.current_version) > 0