ASAPCabinetFE
 
Loading...
Searching...
No Matches
VpsDatabaseUpdater Class Reference

Updates the VPS database file in ASAPCabinetFE. More...

#include <vps_database_updater.h>

+ Collaboration diagram for VpsDatabaseUpdater:

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.
 

Detailed Description

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).

Constructor & Destructor Documentation

◆ VpsDatabaseUpdater()

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.

Parameters
vpsDbPathThe file path for storing the VPS database.

Member Function Documentation

◆ fetchIfNeeded()

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.

Parameters
lastUpdatedPathThe path to the local lastUpdated.json file.
updateFrequencyThe frequency setting (e.g., "startup") to control updates.
progressOptional pointer to LoadingProgress for real-time updates.
Returns
True if the database is valid (exists or updated), false on critical failure.
+ Here is the caller graph for this function:

The documentation for this class was generated from the following files: