mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-22 20:52:49 +00:00
feat(dashboard): check GitHub for a newer release or newer commits
A worker thread asks GitHub's API about update_check_repo: the latest release and, for development and CI builds, how far the build's commit is behind its branch (or main). Unauthenticated, with ETags, every update_check_interval_hours (default 6); offline or rate limited, the last answer stays next to the error and a used-up limit waits for its reset. The main loop logs results, sends them to master (UPDATE_STATUS, again when the link comes back) and pushes update_check to open pages. GET /api/update_check, and POST /api/update_check/check (settings permission, once a minute). Nothing is downloaded or installed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
29
dDashboardServer/notify/UpdateChecker.h
Normal file
29
dDashboardServer/notify/UpdateChecker.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include "json_fwd.hpp"
|
||||
|
||||
/**
|
||||
* Checks GitHub for a newer release of the configured repository (update_check_repo) and, for development builds,
|
||||
* how many commits the build's branch has that the build doesn't. Nothing is ever downloaded or installed.
|
||||
*
|
||||
* Unauthenticated and gentle: at most every update_check_interval_hours (and one "Check now" a minute), with ETags so
|
||||
* unchanged answers don't count against GitHub's rate limit. Requests run on a worker thread; results come back in
|
||||
* Update() on the main loop, which logs them, tells master (UPDATE_STATUS, for its log) and pushes update_check to
|
||||
* open pages. Offline or rate limited, the last good answer stays and the error is shown next to it.
|
||||
*/
|
||||
namespace UpdateChecker {
|
||||
void Initialize();
|
||||
void Shutdown();
|
||||
|
||||
// Main loop: start a check when one is due, take in finished ones. masterConnected: the link to master is up (the
|
||||
// last result is sent again each time it comes up, so a restarted master logs it too)
|
||||
void Update(bool masterConnected);
|
||||
|
||||
// Check as soon as possible (no more than once a minute). Returns false when that was too soon or checks are off.
|
||||
bool CheckNow(std::string& error);
|
||||
|
||||
// The running build and what the last check found, for the About page and /api/update_check
|
||||
nlohmann::json Json();
|
||||
|
||||
void RegisterRoutes();
|
||||
}
|
||||
Reference in New Issue
Block a user