fix(CORE): another attempt to fix the dbimport command line warning (#13449)

This commit is contained in:
Yehonal
2022-10-22 00:21:16 +02:00
committed by GitHub
parent 53219310cf
commit 77a52b8001
10 changed files with 72 additions and 5 deletions

View File

@@ -167,7 +167,7 @@ SourceDirectory = ""
# Description: The path to your MySQL CLI binary.
# If the path is left empty, built-in path from cmake is used.
# Example: "C:/Program Files/MariaDB 10.5/bin/mysql.exe"
# "C:/Program Files/MySQL/MySQL Server 5.6/bin/mysql.exe"
# "C:/Program Files/MySQL/MySQL Server 8.0/bin/mysql.exe"
# "mysql.exe"
# "/usr/bin/mysql"
# Default: ""
@@ -175,6 +175,16 @@ SourceDirectory = ""
MySQLExecutable = ""
#
# TempDir
# Description: Temp directory setting.
# Important: TempDir needs to be quoted, as the string might contain space characters.
# TempDir directory must exists, or the server can't work properly
# Example: "/home/youruser/azerothcore/temp"
# Default: "" - (Temp files will be stored in the current path)
TempDir = ""
#
# IPLocationFile
# Description: The path to your IP2Location database CSV file.

View File

@@ -81,6 +81,16 @@ DataDir = "."
LogsDir = ""
#
# TempDir
# Description: Temp directory setting.
# Important: TempDir needs to be quoted, as the string might contain space characters.
# TempDir directory must exists, or the server can't work properly
# Example: "/home/youruser/azerothcore/temp"
# Default: "" - (Temp files will be stored in the current path)
TempDir = ""
#
# LoginDatabaseInfo
# WorldDatabaseInfo
@@ -193,7 +203,7 @@ SourceDirectory = ""
# MySQLExecutable
# Description: The path to your MySQL CLI binary.
# If the path is left empty, built-in path from cmake is used.
# Example: "C:/Program Files/MySQL/MySQL Server 5.7/bin/mysql.exe"
# Example: "C:/Program Files/MySQL/MySQL Server 8.0/bin/mysql.exe"
# "mysql.exe"
# "/usr/bin/mysql"
# Default: ""

View File

@@ -442,16 +442,29 @@ template<class T>
void DBUpdater<T>::ApplyFile(DatabaseWorkerPool<T>& pool, std::string const& host, std::string const& user,
std::string const& password, std::string const& port_or_socket, std::string const& database, std::string const& ssl, Path const& path)
{
std::string configTempDir = sConfigMgr->GetOption<std::string>("TempDir", "");
auto tempDir = configTempDir.empty() ? std::filesystem::temp_directory_path().string() : configTempDir;
tempDir = Acore::String::AddSuffixIfNotExists(tempDir, std::filesystem::path::preferred_separator);
std::string confFileName = "mysql_ac.conf";
std::ofstream outfile (tempDir + confFileName);
outfile << "[client]\npassword = \"" << password << '"' << std::endl;
outfile.close();
std::vector<std::string> args;
args.reserve(9);
args.emplace_back("--defaults-extra-file="+tempDir + confFileName+"");
// CLI Client connection info
args.emplace_back("-h" + host);
args.emplace_back("-u" + user);
if (!password.empty())
args.emplace_back("-p" + password);
// Check if we want to connect through ip or socket (Unix only)
#ifdef _WIN32