mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-17 09:14:34 +00:00
Big update.
This commit is contained in:
@@ -50,8 +50,8 @@ bool DBUpdaterUtil::CheckExecutable()
|
||||
return true;
|
||||
}
|
||||
|
||||
LOG_FATAL("sql.updates", "Didn't find any executable MySQL binary at \'%s\' or in path, correct the path in the *.conf (\"MySQLExecutable\").",
|
||||
absolute(exe).generic_string().c_str());
|
||||
LOG_FATAL("sql.updates", "Didn't find any executable MySQL binary at \'{}\' or in path, correct the path in the *.conf (\"MySQLExecutable\").",
|
||||
absolute(exe).generic_string());
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -77,10 +77,16 @@ std::string DBUpdater<LoginDatabaseConnection>::GetTableName()
|
||||
return "Auth";
|
||||
}
|
||||
|
||||
template<>
|
||||
std::string DBUpdater<LoginDatabaseConnection>::GetSourceDirectory()
|
||||
{
|
||||
return BuiltInConfig::GetSourceDirectory();
|
||||
}
|
||||
|
||||
template<>
|
||||
std::string DBUpdater<LoginDatabaseConnection>::GetBaseFilesDirectory()
|
||||
{
|
||||
return BuiltInConfig::GetSourceDirectory() + "/data/sql/base/db_auth/";
|
||||
return DBUpdater<LoginDatabaseConnection>::GetSourceDirectory() + "/data/sql/base/db_auth/";
|
||||
}
|
||||
|
||||
template<>
|
||||
@@ -93,7 +99,7 @@ bool DBUpdater<LoginDatabaseConnection>::IsEnabled(uint32 const updateMask)
|
||||
template<>
|
||||
std::string DBUpdater<LoginDatabaseConnection>::GetDBModuleName()
|
||||
{
|
||||
return "db-auth";
|
||||
return "auth";
|
||||
}
|
||||
|
||||
// World Database
|
||||
@@ -109,10 +115,16 @@ std::string DBUpdater<WorldDatabaseConnection>::GetTableName()
|
||||
return "World";
|
||||
}
|
||||
|
||||
template<>
|
||||
std::string DBUpdater<WorldDatabaseConnection>::GetSourceDirectory()
|
||||
{
|
||||
return BuiltInConfig::GetSourceDirectory();
|
||||
}
|
||||
|
||||
template<>
|
||||
std::string DBUpdater<WorldDatabaseConnection>::GetBaseFilesDirectory()
|
||||
{
|
||||
return BuiltInConfig::GetSourceDirectory() + "/data/sql/base/db_world/";
|
||||
return DBUpdater<WorldDatabaseConnection>::GetSourceDirectory() + "/data/sql/base/db_world/";
|
||||
}
|
||||
|
||||
template<>
|
||||
@@ -125,7 +137,7 @@ bool DBUpdater<WorldDatabaseConnection>::IsEnabled(uint32 const updateMask)
|
||||
template<>
|
||||
std::string DBUpdater<WorldDatabaseConnection>::GetDBModuleName()
|
||||
{
|
||||
return "db-world";
|
||||
return "world";
|
||||
}
|
||||
|
||||
// Character Database
|
||||
@@ -141,10 +153,16 @@ std::string DBUpdater<CharacterDatabaseConnection>::GetTableName()
|
||||
return "Character";
|
||||
}
|
||||
|
||||
template<>
|
||||
std::string DBUpdater<CharacterDatabaseConnection>::GetSourceDirectory()
|
||||
{
|
||||
return BuiltInConfig::GetSourceDirectory();
|
||||
}
|
||||
|
||||
template<>
|
||||
std::string DBUpdater<CharacterDatabaseConnection>::GetBaseFilesDirectory()
|
||||
{
|
||||
return BuiltInConfig::GetSourceDirectory() + "/data/sql/base/db_characters/";
|
||||
return DBUpdater<CharacterDatabaseConnection>::GetSourceDirectory() + "/data/sql/base/db_characters/";
|
||||
}
|
||||
|
||||
template<>
|
||||
@@ -157,40 +175,46 @@ bool DBUpdater<CharacterDatabaseConnection>::IsEnabled(uint32 const updateMask)
|
||||
template<>
|
||||
std::string DBUpdater<CharacterDatabaseConnection>::GetDBModuleName()
|
||||
{
|
||||
return "db-characters";
|
||||
return "characters";
|
||||
}
|
||||
|
||||
#ifdef PLAYERBOTS
|
||||
// Playerbot Database
|
||||
#ifdef MOD_PLAYERBOTS
|
||||
// Playerbots Database
|
||||
template<>
|
||||
std::string DBUpdater<PlayerbotDatabaseConnection>::GetConfigEntry()
|
||||
std::string DBUpdater<PlayerbotsDatabaseConnection>::GetConfigEntry()
|
||||
{
|
||||
return "Updates.Playerbot";
|
||||
return "Updates.Playerbots";
|
||||
}
|
||||
|
||||
template<>
|
||||
std::string DBUpdater<PlayerbotDatabaseConnection>::GetTableName()
|
||||
std::string DBUpdater<PlayerbotsDatabaseConnection>::GetTableName()
|
||||
{
|
||||
return "Playerbot";
|
||||
return "Playerbots";
|
||||
}
|
||||
|
||||
template<>
|
||||
std::string DBUpdater<PlayerbotDatabaseConnection>::GetBaseFilesDirectory()
|
||||
std::string DBUpdater<PlayerbotsDatabaseConnection>::GetSourceDirectory()
|
||||
{
|
||||
return BuiltInConfig::GetSourceDirectory() + "/modules/mod-playerbots/sql/base/db_playerbot/";
|
||||
return BuiltInConfig::GetSourceDirectory() + "/modules/mod-playerbots";
|
||||
}
|
||||
|
||||
template<>
|
||||
bool DBUpdater<PlayerbotDatabaseConnection>::IsEnabled(uint32 const updateMask)
|
||||
std::string DBUpdater<PlayerbotsDatabaseConnection>::GetBaseFilesDirectory()
|
||||
{
|
||||
return DBUpdater<PlayerbotsDatabaseConnection>::GetSourceDirectory() + "/sql/playerbots/base/";
|
||||
}
|
||||
|
||||
template<>
|
||||
bool DBUpdater<PlayerbotsDatabaseConnection>::IsEnabled(uint32 const updateMask)
|
||||
{
|
||||
// This way silences warnings under msvc
|
||||
return (updateMask & DatabaseLoader::DATABASE_PLAYERBOT) ? true : false;
|
||||
return (updateMask & DatabaseLoader::DATABASE_PLAYERBOTS) ? true : false;
|
||||
}
|
||||
|
||||
template<>
|
||||
std::string DBUpdater<PlayerbotDatabaseConnection>::GetDBModuleName()
|
||||
std::string DBUpdater<PlayerbotsDatabaseConnection>::GetDBModuleName()
|
||||
{
|
||||
return "db-playerbot";
|
||||
return "db_playerbot";
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -204,15 +228,15 @@ BaseLocation DBUpdater<T>::GetBaseLocationType()
|
||||
template<class T>
|
||||
bool DBUpdater<T>::Create(DatabaseWorkerPool<T>& pool)
|
||||
{
|
||||
LOG_WARN("sql.updates", "Database \"%s\" does not exist, do you want to create it? [yes (default) / no]: ",
|
||||
pool.GetConnectionInfo()->database.c_str());
|
||||
LOG_WARN("sql.updates", "Database \"{}\" does not exist, do you want to create it? [yes (default) / no]: ",
|
||||
pool.GetConnectionInfo()->database);
|
||||
|
||||
std::string answer;
|
||||
std::getline(std::cin, answer);
|
||||
if (!answer.empty() && !(answer.substr(0, 1) == "y"))
|
||||
return false;
|
||||
|
||||
LOG_INFO("sql.updates", "Creating database \"%s\"...", pool.GetConnectionInfo()->database.c_str());
|
||||
LOG_INFO("sql.updates", "Creating database \"{}\"...", pool.GetConnectionInfo()->database);
|
||||
|
||||
// Path of temp file
|
||||
static Path const temp("create_table.sql");
|
||||
@@ -221,7 +245,7 @@ bool DBUpdater<T>::Create(DatabaseWorkerPool<T>& pool)
|
||||
std::ofstream file(temp.generic_string());
|
||||
if (!file.is_open())
|
||||
{
|
||||
LOG_FATAL("sql.updates", "Failed to create temporary query file \"%s\"!", temp.generic_string().c_str());
|
||||
LOG_FATAL("sql.updates", "Failed to create temporary query file \"{}\"!", temp.generic_string());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -236,7 +260,7 @@ bool DBUpdater<T>::Create(DatabaseWorkerPool<T>& pool)
|
||||
}
|
||||
catch (UpdateException&)
|
||||
{
|
||||
LOG_FATAL("sql.updates", "Failed to create database %s! Does the user (named in *.conf) have `CREATE`, `ALTER`, `DROP`, `INSERT` and `DELETE` privileges on the MySQL server?", pool.GetConnectionInfo()->database.c_str());
|
||||
LOG_FATAL("sql.updates", "Failed to create database {}! Does the user (named in *.conf) have `CREATE`, `ALTER`, `DROP`, `INSERT` and `DELETE` privileges on the MySQL server?", pool.GetConnectionInfo()->database);
|
||||
std::filesystem::remove(temp);
|
||||
return false;
|
||||
}
|
||||
@@ -253,23 +277,23 @@ bool DBUpdater<T>::Update(DatabaseWorkerPool<T>& pool, std::string_view modulesL
|
||||
if (!DBUpdaterUtil::CheckExecutable())
|
||||
return false;
|
||||
|
||||
LOG_INFO("sql.updates", "Updating %s database...", DBUpdater<T>::GetTableName().c_str());
|
||||
LOG_INFO("sql.updates", "Updating {} database...", DBUpdater<T>::GetTableName());
|
||||
|
||||
Path const sourceDirectory(BuiltInConfig::GetSourceDirectory());
|
||||
Path const sourceDirectory(DBUpdater<T>::GetSourceDirectory());
|
||||
|
||||
if (!is_directory(sourceDirectory))
|
||||
{
|
||||
LOG_ERROR("sql.updates", "DBUpdater: The given source directory %s does not exist, change the path to the directory where your sql directory exists (for example c:\\source\\trinitycore). Shutting down.",
|
||||
sourceDirectory.generic_string().c_str());
|
||||
LOG_ERROR("sql.updates", "DBUpdater: The given source directory {} does not exist, change the path to the directory where your sql directory exists (for example c:\\source\\trinitycore). Shutting down.",
|
||||
sourceDirectory.generic_string());
|
||||
return false;
|
||||
}
|
||||
|
||||
auto CheckUpdateTable = [&](std::string const& tableName)
|
||||
{
|
||||
auto checkTable = DBUpdater<T>::Retrieve(pool, Acore::StringFormat("SHOW TABLES LIKE '%s'", tableName.c_str()));
|
||||
auto checkTable = DBUpdater<T>::Retrieve(pool, Acore::StringFormatFmt("SHOW TABLES LIKE '{}'", tableName));
|
||||
if (!checkTable)
|
||||
{
|
||||
LOG_WARN("sql.updates", "> Table '%s' not exist! Try add based table", tableName.c_str());
|
||||
LOG_WARN("sql.updates", "> Table '{}' not exist! Try add based table", tableName);
|
||||
|
||||
Path const temp(GetBaseFilesDirectory() + tableName + ".sql");
|
||||
|
||||
@@ -279,7 +303,7 @@ bool DBUpdater<T>::Update(DatabaseWorkerPool<T>& pool, std::string_view modulesL
|
||||
}
|
||||
catch (UpdateException&)
|
||||
{
|
||||
LOG_FATAL("sql.updates", "Failed apply file to database %s! Does the user (named in *.conf) have `INSERT` and `DELETE` privileges on the MySQL server?", pool.GetConnectionInfo()->database.c_str());
|
||||
LOG_FATAL("sql.updates", "Failed apply file to database {}! Does the user (named in *.conf) have `INSERT` and `DELETE` privileges on the MySQL server?", pool.GetConnectionInfo()->database);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -310,13 +334,12 @@ bool DBUpdater<T>::Update(DatabaseWorkerPool<T>& pool, std::string_view modulesL
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string const info = Acore::StringFormat("Containing " SZFMTD " new and " SZFMTD " archived updates.",
|
||||
result.recent, result.archived);
|
||||
std::string const info = Acore::StringFormatFmt("Containing {} new and {} archived updates.", result.recent, result.archived);
|
||||
|
||||
if (!result.updated)
|
||||
LOG_INFO("sql.updates", ">> %s database is up-to-date! %s", DBUpdater<T>::GetTableName().c_str(), info.c_str());
|
||||
LOG_INFO("sql.updates", ">> {} database is up-to-date! {}", DBUpdater<T>::GetTableName(), info);
|
||||
else
|
||||
LOG_INFO("sql.updates", ">> Applied " SZFMTD " %s. %s", result.updated, result.updated == 1 ? "query" : "queries", info.c_str());
|
||||
LOG_INFO("sql.updates", ">> Applied {} {}. {}", result.updated, result.updated == 1 ? "query" : "queries", info);
|
||||
|
||||
LOG_INFO("sql.updates", " ");
|
||||
|
||||
@@ -331,7 +354,7 @@ bool DBUpdater<T>::Update(DatabaseWorkerPool<T>& pool, std::vector<std::string>
|
||||
return false;
|
||||
}
|
||||
|
||||
Path const sourceDirectory(BuiltInConfig::GetSourceDirectory());
|
||||
Path const sourceDirectory(DBUpdater<T>::GetSourceDirectory());
|
||||
if (!is_directory(sourceDirectory))
|
||||
{
|
||||
return false;
|
||||
@@ -339,7 +362,7 @@ bool DBUpdater<T>::Update(DatabaseWorkerPool<T>& pool, std::vector<std::string>
|
||||
|
||||
auto CheckUpdateTable = [&](std::string const& tableName)
|
||||
{
|
||||
auto checkTable = DBUpdater<T>::Retrieve(pool, Acore::StringFormat("SHOW TABLES LIKE '%s'", tableName.c_str()));
|
||||
auto checkTable = DBUpdater<T>::Retrieve(pool, Acore::StringFormatFmt("SHOW TABLES LIKE '{}'", tableName));
|
||||
if (!checkTable)
|
||||
{
|
||||
Path const temp(GetBaseFilesDirectory() + tableName + ".sql");
|
||||
@@ -396,20 +419,20 @@ bool DBUpdater<T>::Populate(DatabaseWorkerPool<T>& pool)
|
||||
if (!DBUpdaterUtil::CheckExecutable())
|
||||
return false;
|
||||
|
||||
LOG_INFO("sql.updates", "Database %s is empty, auto populating it...", DBUpdater<T>::GetTableName().c_str());
|
||||
LOG_INFO("sql.updates", "Database {} is empty, auto populating it...", DBUpdater<T>::GetTableName());
|
||||
|
||||
std::string const DirPathStr = DBUpdater<T>::GetBaseFilesDirectory();
|
||||
|
||||
Path const DirPath(DirPathStr);
|
||||
if (!std::filesystem::is_directory(DirPath))
|
||||
{
|
||||
LOG_ERROR("sql.updates", ">> Directory \"%s\" not exist", DirPath.generic_string().c_str());
|
||||
LOG_ERROR("sql.updates", ">> Directory \"{}\" not exist", DirPath.generic_string());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (DirPath.empty())
|
||||
{
|
||||
LOG_ERROR("sql.updates", ">> Directory \"%s\" is empty", DirPath.generic_string().c_str());
|
||||
LOG_ERROR("sql.updates", ">> Directory \"{}\" is empty", DirPath.generic_string());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -424,7 +447,7 @@ bool DBUpdater<T>::Populate(DatabaseWorkerPool<T>& pool)
|
||||
|
||||
if (!FilesCount)
|
||||
{
|
||||
LOG_ERROR("sql.updates", ">> In directory \"%s\" not exist '*.sql' files", DirPath.generic_string().c_str());
|
||||
LOG_ERROR("sql.updates", ">> In directory \"{}\" not exist '*.sql' files", DirPath.generic_string());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -433,7 +456,7 @@ bool DBUpdater<T>::Populate(DatabaseWorkerPool<T>& pool)
|
||||
if (itr->path().extension() != ".sql")
|
||||
continue;
|
||||
|
||||
LOG_INFO("sql.updates", ">> Applying \'%s\'...", itr->path().filename().generic_string().c_str());
|
||||
LOG_INFO("sql.updates", ">> Applying \'{}\'...", itr->path().filename().generic_string());
|
||||
|
||||
try
|
||||
{
|
||||
@@ -534,12 +557,12 @@ void DBUpdater<T>::ApplyFile(DatabaseWorkerPool<T>& pool, std::string const& hos
|
||||
|
||||
if (ret != EXIT_SUCCESS)
|
||||
{
|
||||
LOG_FATAL("sql.updates", "Applying of file \'%s\' to database \'%s\' failed!" \
|
||||
LOG_FATAL("sql.updates", "Applying of file \'{}\' to database \'{}\' failed!" \
|
||||
" If you are a user, please pull the latest revision from the repository. "
|
||||
"Also make sure you have not applied any of the databases with your sql client. "
|
||||
"You cannot use auto-update system and import sql files from AzerothCore repository with your sql client. "
|
||||
"If you are a developer, please fix your sql query.",
|
||||
path.generic_string().c_str(), pool.GetConnectionInfo()->database.c_str());
|
||||
path.generic_string(), pool.GetConnectionInfo()->database);
|
||||
|
||||
throw UpdateException("update failed");
|
||||
}
|
||||
@@ -549,6 +572,6 @@ template class AC_DATABASE_API DBUpdater<LoginDatabaseConnection>;
|
||||
template class AC_DATABASE_API DBUpdater<WorldDatabaseConnection>;
|
||||
template class AC_DATABASE_API DBUpdater<CharacterDatabaseConnection>;
|
||||
|
||||
#ifdef PLAYERBOTS
|
||||
template class AC_DATABASE_API DBUpdater<PlayerbotDatabaseConnection>;
|
||||
#ifdef MOD_PLAYERBOTS
|
||||
template class AC_DATABASE_API DBUpdater<PlayerbotsDatabaseConnection>;
|
||||
#endif
|
||||
|
||||
@@ -71,6 +71,7 @@ public:
|
||||
|
||||
static inline std::string GetConfigEntry();
|
||||
static inline std::string GetTableName();
|
||||
static std::string GetSourceDirectory();
|
||||
static std::string GetBaseFilesDirectory();
|
||||
static bool IsEnabled(uint32 const updateMask);
|
||||
static BaseLocation GetBaseLocationType();
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include "DBUpdater.h"
|
||||
#include "Field.h"
|
||||
#include "Log.h"
|
||||
#include "QueryResult.h"
|
||||
#include "Tokenize.h"
|
||||
#include "Util.h"
|
||||
#include <fstream>
|
||||
@@ -84,7 +83,7 @@ void UpdateFetcher::FillFileListRecursively(Path const& path, LocaleFileStorage&
|
||||
}
|
||||
else if (itr->path().extension() == ".sql")
|
||||
{
|
||||
LOG_TRACE("sql.updates", "Added locale file \"%s\" state '%s'.", itr->path().filename().generic_string().c_str(), AppliedFileEntry::StateConvert(state).c_str());
|
||||
LOG_TRACE("sql.updates", "Added locale file \"{}\" state '{}'.", itr->path().filename().generic_string(), AppliedFileEntry::StateConvert(state));
|
||||
|
||||
LocaleFileEntry const entry = { itr->path(), state };
|
||||
|
||||
@@ -92,8 +91,8 @@ void UpdateFetcher::FillFileListRecursively(Path const& path, LocaleFileStorage&
|
||||
// Because elements are only compared by their filenames, this is ok
|
||||
if (storage.find(entry) != storage.end())
|
||||
{
|
||||
LOG_FATAL("sql.updates", "Duplicate filename \"%s\" occurred. Because updates are ordered " \
|
||||
"by their filenames, every name needs to be unique!", itr->path().generic_string().c_str());
|
||||
LOG_FATAL("sql.updates", "Duplicate filename \"{}\" occurred. Because updates are ordered " \
|
||||
"by their filenames, every name needs to be unique!", itr->path().generic_string());
|
||||
|
||||
throw UpdateException("Updating failed, see the log for details.");
|
||||
}
|
||||
@@ -120,7 +119,7 @@ UpdateFetcher::DirectoryStorage UpdateFetcher::ReceiveIncludedDirectories() cons
|
||||
DirectoryEntry const entry = {p, AppliedFileEntry::StateConvert("MODULE")};
|
||||
directories.push_back(entry);
|
||||
|
||||
LOG_TRACE("sql.updates", "Added applied extra file \"%s\" from remote.", p.filename().generic_string().c_str());
|
||||
LOG_TRACE("sql.updates", "Added applied extra file \"{}\" from remote.", p.filename().generic_string());
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -133,8 +132,8 @@ UpdateFetcher::DirectoryStorage UpdateFetcher::ReceiveIncludedDirectories() cons
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
std::string path = fields[0].GetString();
|
||||
std::string state = fields[1].GetString();
|
||||
std::string path = fields[0].Get<std::string>();
|
||||
std::string state = fields[1].Get<std::string>();
|
||||
if (path.substr(0, 1) == "$")
|
||||
path = _sourceDirectory->generic_string() + path.substr(1);
|
||||
|
||||
@@ -142,14 +141,14 @@ UpdateFetcher::DirectoryStorage UpdateFetcher::ReceiveIncludedDirectories() cons
|
||||
|
||||
if (!is_directory(p))
|
||||
{
|
||||
LOG_WARN("sql.updates", "DBUpdater: Given update include directory \"%s\" does not exist, skipped!", p.generic_string().c_str());
|
||||
LOG_WARN("sql.updates", "DBUpdater: Given update include directory \"{}\" does not exist, skipped!", p.generic_string());
|
||||
continue;
|
||||
}
|
||||
|
||||
DirectoryEntry const entry = {p, AppliedFileEntry::StateConvert(state)};
|
||||
directories.push_back(entry);
|
||||
|
||||
LOG_TRACE("sql.updates", "Added applied file \"%s\" '%s' state from remote.", p.filename().generic_string().c_str(), state.c_str());
|
||||
LOG_TRACE("sql.updates", "Added applied file \"{}\" '{}' state from remote.", p.filename().generic_string(), state);
|
||||
|
||||
} while (result->NextRow());
|
||||
|
||||
@@ -163,7 +162,7 @@ UpdateFetcher::DirectoryStorage UpdateFetcher::ReceiveIncludedDirectories() cons
|
||||
// data/sql
|
||||
for (auto const& itr : moduleList)
|
||||
{
|
||||
std::string path = _sourceDirectory->generic_string() + "/modules/" + itr + "/data/sql/" + _dbModuleName; // modules/mod-name/data/sql/db-world
|
||||
std::string path = _sourceDirectory->generic_string() + "/modules/" + itr + "/sql/" + _dbModuleName; // modules/mod-name/sql/world
|
||||
|
||||
Path const p(path);
|
||||
if (!is_directory(p))
|
||||
@@ -174,7 +173,7 @@ UpdateFetcher::DirectoryStorage UpdateFetcher::ReceiveIncludedDirectories() cons
|
||||
DirectoryEntry const entry = { p, AppliedFileEntry::StateConvert("MODULE") };
|
||||
directories.push_back(entry);
|
||||
|
||||
LOG_TRACE("sql.updates", "Added applied modules file \"%s\" from remote.", p.filename().generic_string().c_str());
|
||||
LOG_TRACE("sql.updates", "Added applied modules file \"{}\" from remote.", p.filename().generic_string());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,7 +194,7 @@ UpdateFetcher::AppliedFileStorage UpdateFetcher::ReceiveAppliedFiles() const
|
||||
|
||||
AppliedFileEntry const entry =
|
||||
{
|
||||
fields[0].GetString(), fields[1].GetString(), AppliedFileEntry::StateConvert(fields[2].GetString()), fields[3].GetUInt64()
|
||||
fields[0].Get<std::string>(), fields[1].Get<std::string>(), AppliedFileEntry::StateConvert(fields[2].Get<std::string>()), fields[3].Get<uint64>()
|
||||
};
|
||||
|
||||
map.emplace(entry.name, entry);
|
||||
@@ -209,10 +208,10 @@ std::string UpdateFetcher::ReadSQLUpdate(Path const& file) const
|
||||
std::ifstream in(file.c_str());
|
||||
if (!in.is_open())
|
||||
{
|
||||
LOG_FATAL("sql.updates", "Failed to open the sql update \"%s\" for reading! "
|
||||
LOG_FATAL("sql.updates", "Failed to open the sql update \"{}\" for reading! "
|
||||
"Stopping the server to keep the database integrity, "
|
||||
"try to identify and solve the issue or disable the database updater.",
|
||||
file.generic_string().c_str());
|
||||
file.generic_string());
|
||||
|
||||
throw UpdateException("Opening the sql update failed!");
|
||||
}
|
||||
@@ -263,7 +262,7 @@ UpdateResult UpdateFetcher::Update(bool const redundancyChecks,
|
||||
auto filePath = sqlFile.first;
|
||||
auto fileState = sqlFile.second;
|
||||
|
||||
LOG_DEBUG("sql.updates", "Checking update \"%s\"...", filePath.filename().generic_string().c_str());
|
||||
LOG_DEBUG("sql.updates", "Checking update \"{}\"...", filePath.filename().generic_string());
|
||||
|
||||
AppliedFileStorage::const_iterator iter = applied.find(filePath.filename().string());
|
||||
if (iter != applied.end())
|
||||
@@ -306,15 +305,15 @@ UpdateResult UpdateFetcher::Update(bool const redundancyChecks,
|
||||
// Conflict!
|
||||
if (localeIter != available.end())
|
||||
{
|
||||
LOG_WARN("sql.updates", ">> It seems like the update \"%s\" \'%s\' was renamed, but the old file is still there! " \
|
||||
"Treating it as a new file! (It is probably an unmodified copy of the file \"%s\")",
|
||||
filePath.filename().string().c_str(), hash.substr(0, 7).c_str(),
|
||||
localeIter->first.filename().string().c_str());
|
||||
LOG_WARN("sql.updates", ">> It seems like the update \"{}\" \'{}\' was renamed, but the old file is still there! " \
|
||||
"Treating it as a new file! (It is probably an unmodified copy of the file \"{}\")",
|
||||
filePath.filename().string(), hash.substr(0, 7),
|
||||
localeIter->first.filename().string());
|
||||
}
|
||||
else // It is safe to treat the file as renamed here
|
||||
{
|
||||
LOG_INFO("sql.updates", ">> Renaming update \"%s\" to \"%s\" \'%s\'.",
|
||||
hashIter->second.c_str(), filePath.filename().string().c_str(), hash.substr(0, 7).c_str());
|
||||
LOG_INFO("sql.updates", ">> Renaming update \"{}\" to \"{}\" \'{}\'.",
|
||||
hashIter->second, filePath.filename().string(), hash.substr(0, 7));
|
||||
|
||||
RenameEntry(hashIter->second, filePath.filename().string());
|
||||
applied.erase(hashIter->second);
|
||||
@@ -324,8 +323,8 @@ UpdateResult UpdateFetcher::Update(bool const redundancyChecks,
|
||||
// Apply the update if it was never seen before.
|
||||
else
|
||||
{
|
||||
LOG_INFO("sql.updates", ">> Applying update \"%s\" \'%s\'...",
|
||||
filePath.filename().string().c_str(), hash.substr(0, 7).c_str());
|
||||
LOG_INFO("sql.updates", ">> Applying update \"{}\" \'{}\'...",
|
||||
filePath.filename().string(), hash.substr(0, 7));
|
||||
}
|
||||
}
|
||||
// Rehash the update entry if it exists in our database with an empty hash.
|
||||
@@ -333,29 +332,29 @@ UpdateResult UpdateFetcher::Update(bool const redundancyChecks,
|
||||
{
|
||||
mode = MODE_REHASH;
|
||||
|
||||
LOG_INFO("sql.updates", ">> Re-hashing update \"%s\" \'%s\'...", filePath.filename().string().c_str(),
|
||||
hash.substr(0, 7).c_str());
|
||||
LOG_INFO("sql.updates", ">> Re-hashing update \"{}\" \'{}\'...", filePath.filename().string(),
|
||||
hash.substr(0, 7));
|
||||
}
|
||||
else
|
||||
{
|
||||
// If the hash of the files differs from the one stored in our database, reapply the update (because it changed).
|
||||
if (iter->second.hash != hash)
|
||||
{
|
||||
LOG_INFO("sql.updates", ">> Reapplying update \"%s\" \'%s\' -> \'%s\' (it changed)...", filePath.filename().string().c_str(),
|
||||
iter->second.hash.substr(0, 7).c_str(), hash.substr(0, 7).c_str());
|
||||
LOG_INFO("sql.updates", ">> Reapplying update \"{}\" \'{}\' -> \'{}\' (it changed)...", filePath.filename().string(),
|
||||
iter->second.hash.substr(0, 7), hash.substr(0, 7));
|
||||
}
|
||||
else
|
||||
{
|
||||
// If the file wasn't changed and just moved, update its state (if necessary).
|
||||
if (iter->second.state != fileState)
|
||||
{
|
||||
LOG_DEBUG("sql.updates", ">> Updating the state of \"%s\" to \'%s\'...",
|
||||
filePath.filename().string().c_str(), AppliedFileEntry::StateConvert(fileState).c_str());
|
||||
LOG_DEBUG("sql.updates", ">> Updating the state of \"{}\" to \'{}\'...",
|
||||
filePath.filename().string(), AppliedFileEntry::StateConvert(fileState));
|
||||
|
||||
UpdateState(filePath.filename().string(), fileState);
|
||||
}
|
||||
|
||||
LOG_DEBUG("sql.updates", ">> Update is already applied and matches the hash \'%s\'.", hash.substr(0, 7).c_str());
|
||||
LOG_DEBUG("sql.updates", ">> Update is already applied and matches the hash \'{}\'.", hash.substr(0, 7));
|
||||
|
||||
applied.erase(iter);
|
||||
return;
|
||||
@@ -369,7 +368,7 @@ UpdateResult UpdateFetcher::Update(bool const redundancyChecks,
|
||||
{
|
||||
case MODE_APPLY:
|
||||
speed = Apply(filePath);
|
||||
/* fallthrough */
|
||||
[[fallthrough]];
|
||||
case MODE_REHASH:
|
||||
UpdateEntry(file, speed);
|
||||
break;
|
||||
@@ -407,13 +406,13 @@ UpdateResult UpdateFetcher::Update(bool const redundancyChecks,
|
||||
if (entry.second.state != MODULE)
|
||||
{
|
||||
LOG_WARN("sql.updates",
|
||||
">> The file \'%s\' was applied to the database, but is missing in"
|
||||
">> The file \'{}\' was applied to the database, but is missing in"
|
||||
" your update directory now!",
|
||||
entry.first.c_str());
|
||||
entry.first);
|
||||
|
||||
if (doCleanup)
|
||||
{
|
||||
LOG_INFO("sql.updates", "Deleting orphaned entry \'%s\'...", entry.first.c_str());
|
||||
LOG_INFO("sql.updates", "Deleting orphaned entry \'{}\'...", entry.first);
|
||||
toCleanup.insert(entry);
|
||||
}
|
||||
}
|
||||
@@ -426,7 +425,7 @@ UpdateResult UpdateFetcher::Update(bool const redundancyChecks,
|
||||
else
|
||||
{
|
||||
LOG_ERROR("sql.updates",
|
||||
"Cleanup is disabled! There were " SZFMTD " dirty files applied to your database, "
|
||||
"Cleanup is disabled! There were {} dirty files applied to your database, "
|
||||
"but they are now missing in your source directory!",
|
||||
toCleanup.size());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user