Updates the VPS database file in ASAPCabinetFE. More...
#include <vps_database_updater.h>
Public Member Functions | |
VpsDatabaseUpdater (const std::string &vpsDbPath) | |
Constructs a VpsDatabaseUpdater instance. | |
bool | fetchIfNeeded (const std::string &lastUpdatedPath, const std::string &updateFrequency, LoadingProgress *progress=nullptr) |
Fetches the VPS database if an update is needed. | |
Updates the VPS database file in ASAPCabinetFE.
This class handles the updating of the VPS database (vpsdb.json) by checking a remote lastUpdated.json file for the latest timestamp and downloading the database if needed. It uses CURL for HTTP requests, supports multiple fallback URLs, and tracks progress with LoadingProgress. The update frequency and paths are configurable via input parameters, with potential for configUI enhancements (e.g., custom URLs).
VpsDatabaseUpdater::VpsDatabaseUpdater | ( | const std::string & | vpsDbPath | ) |
Constructs a VpsDatabaseUpdater instance.
Initializes the updater with the path where the VPS database file will be stored. This path is used as the target for downloaded updates.
vpsDbPath | The file path for storing the VPS database. |
bool VpsDatabaseUpdater::fetchIfNeeded | ( | const std::string & | lastUpdatedPath, |
const std::string & | updateFrequency, | ||
LoadingProgress * | progress = nullptr |
||
) |
Fetches the VPS database if an update is needed.
Checks the last updated timestamp against the local copy (from lastUpdatedPath) and downloads vpsdb.json from a predefined URL if the remote version is newer or the local file is missing. The update frequency (e.g., "startup") determines if the check occurs. Progress is tracked via LoadingProgress if provided.
lastUpdatedPath | The path to the local lastUpdated.json file. |
updateFrequency | The frequency setting (e.g., "startup") to control updates. |
progress | Optional pointer to LoadingProgress for real-time updates. |