Skip to content

Commit f026c08

Browse files
committed
fix(log): charset
修复log文件上传的路径编码问题
1 parent 4be4d33 commit f026c08

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

Dice/DiceJob.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,8 +500,8 @@ void log_put(AttrObject& job) {
500500
"ap-southeast-1");
501501
if (job->at("ret") == "SUCCESS") {
502502
#endif //_Win32
503-
job->at("log_file") = nameLog;
504-
job->at("log_url") = "https://logpainter.kokona.tech/?s3=" + nameLog;
503+
job->set("log_file",nameLog);
504+
job->set("log_url", "https://logpainter.kokona.tech/?s3=" + nameLog);
505505
reply(job, "{strLogUpSuccess}");
506506
}
507507
else if (++cntExec > 2) {

Dice/DicePython.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ PYDEF(getDiceID) {
690690
}
691691
PYDEF(getDiceDir) {
692692
auto dir{ DiceDir.wstring() };
693-
return PyUnicode_FromUnicode(dir.c_str(), (Py_ssize_t)dir.length());
693+
return PyUnicode_FromWideChar(dir.c_str(), (Py_ssize_t)dir.length());
694694
}
695695
typedef struct {
696696
PyObject_HEAD
@@ -1170,11 +1170,12 @@ PyGlobal::PyGlobal() {
11701170
|| std::filesystem::exists((dirPy = dirExe) / "python3.dll")) {
11711171
//Py_SetPythonHome(dirPy.wstring().c_str());
11721172
PyConfig_SetString(&config, &config.home, dirPy.wstring().c_str());
1173+
//Py_SetProgramName(L"DiceMaid");
1174+
PyConfig_SetString(&config, &config.program_name, L"DiceMaid");
11731175
//Py_SetPath((dirPy / "python311.zip").wstring().c_str());
11741176
PyWideStringList_Append(&config.module_search_paths, (dirPy / "python311.zip").wstring().c_str());
11751177
}
11761178
status = PyConfig_Read(&config);
1177-
Py_SetProgramName(L"DiceMaid");
11781179
try {
11791180
static auto import_dice = PyImport_AppendInittab(DiceModuleName, PyInit_DiceMaid);
11801181
if (import_dice) {

Dice/DiceSession.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void LogInfo::append(const string& s) {
2929
}
3030

3131
bool DiceSession::empty()const {
32-
return dict.empty() && player->empty() && obs->empty() && !logger.tLastMsg && decks.empty();
32+
return dict.empty() && player->empty() && obs->empty() && !logger.tStart && decks.empty();
3333
}
3434
bool DiceSession::has(const string& key)const {
3535
static std::unordered_set<string> items{ "name", "gms", "pls", "obs", "log_name", "log_file" };
@@ -256,7 +256,7 @@ void DiceSession::log_end(DiceEvent* msg) {
256256
return;
257257
}
258258
msg->set("log_file", logger.fileLog);
259-
msg->set("log_path", log_path().string());
259+
msg->set("log_path", log_path().u8string());
260260
msg->replyMsg("strLogEnd");
261261
update();
262262
msg->set("hook","LogEnd");

Dice/EncodingConvert.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ std::string UTF8toLocal(const std::string& str) {
150150
#ifdef _WIN32
151151
return UTF8toGBK(str);
152152
#else
153-
return str
153+
return str;
154154
#endif
155155
}
156156
std::string GBKtoLocal(const std::string& strGBK){
@@ -211,7 +211,7 @@ std::wstring UTF8toU(const std::string& strUTF8) {
211211
delete[] strUTF16;
212212
return wstrOut;
213213
#else
214-
return ConvertEncoding<char>(strUTF8, "utf-8", "gb18030");
214+
return ConvertEncoding<wchar_t>(strUTF8, "utf-8", "utf-32le");
215215
#endif
216216
}
217217

0 commit comments

Comments
 (0)