graph: allow graphs to be auto-collected (controlled via yb_graph_auto_collect_db)

By default it's off, but it's allow bot to scan graph directory, do a diff with a graph db server and upload every single graph file that do not exist in central database. This is done in a separate thread and do not block server process, and only once server/game is started, not on change level. Also, it's not working on currently started map.
This commit is contained in:
jeefo 2024-01-30 14:37:14 +03:00
commit 46ebbeea57
No known key found for this signature in database
GPG key ID: 927BCA0779BEA8ED
8 changed files with 200 additions and 11 deletions

View file

@ -49,7 +49,7 @@ template <typename U> bool BotStorage::load (SmallArray <U> &data, ExtenHeader *
auto downloadAddress = cv_graph_url.str ();
auto toDownload = buildPath (storageToBotFile (type.option), false);
auto fromDownload = strings.format ("http://%s/graph/%s.graph", downloadAddress, lowercaseMapName);
auto fromDownload = strings.format ("%s://%s/graph/%s.graph", product.httpScheme, downloadAddress, lowercaseMapName);
// try to download
if (http.downloadFile (fromDownload, toDownload)) {
@ -301,7 +301,7 @@ template <typename U> BotStorage::SaveLoadData BotStorage::guessType () {
#else
String BotStorage::buildPath (int32_t file, bool isMemoryLoad) {
String BotStorage::buildPath (int32_t file, bool isMemoryLoad, bool withoutMapName) {
using FilePath = Twin <String, String>;
static HashMap <int32_t, FilePath> paths = {
@ -342,7 +342,7 @@ String BotStorage::buildPath (int32_t file, bool isMemoryLoad) {
strftime (timebuf, StringBuffer::StaticBufferSize, "L%d%m%Y", &timeinfo);
path.emplace (strings.format ("%s_%s.%s", product.nameLower, timebuf, paths[file].second));
}
else {
else if (!withoutMapName) {
String mapName = game.getMapName ();
path.emplace (strings.format ("%s.%s", mapName.lowercase (), paths[file].second));
}