Add a "Check now" button to the Firmware update card
Build and push server image / build-and-push (push) Successful in 36s
Build and push server image / build-and-push (push) Successful in 36s
GET /api/firmware/check's 15-minute throttle meant a genuinely new Gitea release could sit invisible in the UI for up to that long even though POST /api/firmware/apply-latest (unthrottled) would've picked it up immediately. New ?force=true bypasses the throttle for an explicit check; the button wires it up and surfaces errors instead of failing silently like the passive poll.
This commit is contained in:
+8
-3
@@ -529,7 +529,7 @@ def _apply_gitea_update(cfg: config.FrameConfig) -> str:
|
||||
|
||||
|
||||
@app.get("/api/firmware/check", dependencies=[Depends(require_access_token)])
|
||||
def api_firmware_check():
|
||||
def api_firmware_check(force: bool = False):
|
||||
"""Throttled check of the configured Gitea repo's latest release
|
||||
(gitea_releases.UPDATE_CHECK_INTERVAL_S) -- cheap, since it only reads
|
||||
the release's tag name, not its binaries. If firmware_auto_update is
|
||||
@@ -538,13 +538,18 @@ def api_firmware_check():
|
||||
Applying (auto or manual) needs to know the frame's board, which is
|
||||
learned from the device's own X-Frame-Board header rather than
|
||||
picked by the user -- update_available stays false until a device
|
||||
has checked in at least once, regardless of what Gitea has."""
|
||||
has checked in at least once, regardless of what Gitea has.
|
||||
|
||||
force=true (the "Check now" button) bypasses the throttle and always
|
||||
hits Gitea -- otherwise a genuinely new release can sit invisible in
|
||||
the UI for up to the full throttle interval even though it's already
|
||||
live, since the passive poll won't look again until then."""
|
||||
cfg = config.load()
|
||||
if not cfg.firmware_update_repo_url:
|
||||
return {"enabled": False}
|
||||
|
||||
now = time.time()
|
||||
if now - cfg.firmware_update_checked_at >= gitea_releases.UPDATE_CHECK_INTERVAL_S:
|
||||
if force or now - cfg.firmware_update_checked_at >= gitea_releases.UPDATE_CHECK_INTERVAL_S:
|
||||
# Deliberately not updated on failure (see below) -- checked_at only
|
||||
# advances on a successful reach, so a Gitea outage gets retried
|
||||
# every poll instead of waiting out the full throttle interval.
|
||||
|
||||
Reference in New Issue
Block a user