From 719159e2074ac2d0902c70bdd3c7a39e0d311bbe Mon Sep 17 00:00:00 2001 From: Naios Date: Sun, 21 Feb 2016 15:52:42 +0100 Subject: Core/Common: Add a generic config helper to access built-in overwriteable paths. * Adds CMAKE_COMMAND and CMAKE_BINARY_DIR to revision_data.h * Move the source and mysql exe path handling out of the DBUpdater. * Make some Config methods const for correctness. * Remove C & CXX flags from revision_data.h (was unused and didn't capture all cxx vars) * Reorder the link order to prevent `ld` from ignoring the file * Ref #15671 --- src/server/database/Updater/DBUpdater.cpp | 33 ++++++++++--------------------- src/server/database/Updater/DBUpdater.h | 4 +--- 2 files changed, 11 insertions(+), 26 deletions(-) (limited to 'src/server/database') diff --git a/src/server/database/Updater/DBUpdater.cpp b/src/server/database/Updater/DBUpdater.cpp index b36ccd37691..ab4b767b104 100644 --- a/src/server/database/Updater/DBUpdater.cpp +++ b/src/server/database/Updater/DBUpdater.cpp @@ -21,6 +21,7 @@ #include "UpdateFetcher.h" #include "DatabaseLoader.h" #include "Config.h" +#include "BuiltInConfig.h" #include #include @@ -35,23 +36,17 @@ using namespace boost::process; using namespace boost::process::initializers; using namespace boost::iostreams; -std::string DBUpdaterUtil::GetMySqlCli() +std::string DBUpdaterUtil::GetCorrectedMySQLExecutable() { if (!corrected_path().empty()) return corrected_path(); else - { - std::string const entry = sConfigMgr->GetStringDefault("Updates.MySqlCLIPath", ""); - if (!entry.empty()) - return entry; - else - return GitRevision::GetMySQLExecutable(); - } + return BuiltInConfig::GetMySQLExecutable(); } bool DBUpdaterUtil::CheckExecutable() { - boost::filesystem::path exe(GetMySqlCli()); + boost::filesystem::path exe(GetCorrectedMySQLExecutable()); if (!exists(exe)) { exe.clear(); @@ -85,16 +80,6 @@ std::string& DBUpdaterUtil::corrected_path() return path; } -template -std::string DBUpdater::GetSourceDirectory() -{ - std::string const entry = sConfigMgr->GetStringDefault("Updates.SourcePath", ""); - if (!entry.empty()) - return entry; - else - return GitRevision::GetSourceDirectory(); -} - // Auth Database template<> std::string DBUpdater::GetConfigEntry() @@ -111,7 +96,8 @@ std::string DBUpdater::GetTableName() template<> std::string DBUpdater::GetBaseFile() { - return DBUpdater::GetSourceDirectory() + "/sql/base/auth_database.sql"; + return BuiltInConfig::GetSourceDirectory() + + "/sql/base/auth_database.sql"; } template<> @@ -169,7 +155,8 @@ std::string DBUpdater::GetTableName() template<> std::string DBUpdater::GetBaseFile() { - return DBUpdater::GetSourceDirectory() + "/sql/base/characters_database.sql"; + return BuiltInConfig::GetSourceDirectory() + + "/sql/base/characters_database.sql"; } template<> @@ -271,7 +258,7 @@ bool DBUpdater::Update(DatabaseWorkerPool& pool) TC_LOG_INFO("sql.updates", "Updating %s database...", DBUpdater::GetTableName().c_str()); - Path const sourceDirectory(GetSourceDirectory()); + Path const sourceDirectory(BuiltInConfig::GetSourceDirectory()); if (!is_directory(sourceDirectory)) { @@ -442,7 +429,7 @@ void DBUpdater::ApplyFile(DatabaseWorkerPool& pool, std::string const& hos boost::process::pipe errPipe = create_pipe(); child c = execute(run_exe( - boost::filesystem::absolute(DBUpdaterUtil::GetMySqlCli()).generic_string()), + boost::filesystem::absolute(DBUpdaterUtil::GetCorrectedMySQLExecutable()).generic_string()), set_args(args), bind_stdin(source), throw_on_error(), bind_stdout(file_descriptor_sink(outPipe.sink, close_handle)), bind_stderr(file_descriptor_sink(errPipe.sink, close_handle))); diff --git a/src/server/database/Updater/DBUpdater.h b/src/server/database/Updater/DBUpdater.h index c9792ffe060..dbb897d2527 100644 --- a/src/server/database/Updater/DBUpdater.h +++ b/src/server/database/Updater/DBUpdater.h @@ -57,7 +57,7 @@ struct UpdateResult class DBUpdaterUtil { public: - static std::string GetMySqlCli(); + static std::string GetCorrectedMySQLExecutable(); static bool CheckExecutable(); @@ -71,8 +71,6 @@ class DBUpdater public: using Path = boost::filesystem::path; - static std::string GetSourceDirectory(); - static inline std::string GetConfigEntry(); static inline std::string GetTableName(); -- cgit v1.2.3