From e24681332d3c11141c89415a3eda87ad6b6f242d Mon Sep 17 00:00:00 2001 From: nessi Date: Fri, 13 Feb 2026 09:01:42 +0100 Subject: [PATCH] Simplify upstream version check mechanism Updated the "Check for Updates" functionality to rely solely on the latest published release in the upstream repository. Removed redundant code for fetching tags and commits, enhancing maintainability and reducing complexity. --- README.md | 2 +- backend/app/services/service_info.py | 26 +++----------------------- 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index fe1b42f..7292bf8 100644 --- a/README.md +++ b/README.md @@ -236,7 +236,7 @@ Recommended values for `VITE_API_URL`: - Sidebar entry for runtime and system details - Displays current version, latest known version, uptime, host, and platform -- "Check for Updates" against the official upstream repository (`git.nesterovic.cc/nessi/NexaPG`) +- "Check for Updates" against the latest published release in the official upstream repository (`git.nesterovic.cc/nessi/NexaPG`) - Version/update source are read-only in UI (maintainer-controlled in code/release flow) ## Target Owner Notifications diff --git a/backend/app/services/service_info.py b/backend/app/services/service_info.py index b19a10f..c1550f3 100644 --- a/backend/app/services/service_info.py +++ b/backend/app/services/service_info.py @@ -65,8 +65,6 @@ def _get_json(url: str): def _fetch_latest_from_upstream_sync() -> tuple[str, str]: latest_release_url = f"{UPSTREAM_REPO_API}/releases/latest" - tags_url = f"{UPSTREAM_REPO_API}/tags?page=1&limit=1" - commits_url = f"{UPSTREAM_REPO_API}/commits?sha=main&page=1&limit=1" try: release = _get_json(latest_release_url) @@ -74,27 +72,9 @@ def _fetch_latest_from_upstream_sync() -> tuple[str, str]: tag = (release.get("tag_name") or release.get("name") or "").strip() if tag: return tag[:64], "release" - except Exception: - pass - - try: - tags = _get_json(tags_url) - if isinstance(tags, list) and tags: - first = tags[0] if isinstance(tags[0], dict) else {} - tag = (first.get("name") or "").strip() - if tag: - return tag[:64], "tag" - except Exception: - pass - - commits = _get_json(commits_url) - if isinstance(commits, list) and commits: - first = commits[0] if isinstance(commits[0], dict) else {} - sha = (first.get("sha") or "").strip() - if sha: - short = sha[:7] - return f"commit-{short}", "commit" - raise ValueError("Could not fetch release/tag/commit from upstream repository") + except Exception as exc: + raise ValueError(f"Could not fetch latest release from upstream repository: {exc}") from exc + raise ValueError("No published release found in upstream repository") async def fetch_latest_from_upstream() -> tuple[str | None, str | None, str | None]: