Skip to content

Commit ac575b2

Browse files
committed
fixed:crt runtime on windows
1 parent b2d8f50 commit ac575b2

2 files changed

Lines changed: 12 additions & 15 deletions

File tree

‎XEngine_Source/XEngine_StorageApp/StorageApp_FTP.cpp‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ static void XEngine_FTPUPload_Thread(xstring lpszClientAddr, xstring lpszFileNam
125125
Session_FTP_GetRetr(lpszClientAddr.c_str(), &nPos);
126126
if (nPos > 0)
127127
{
128-
pSt_File = _xfopenA(lpszFileName.c_str(), _X("rb+"), true);
128+
pSt_File = _xtfopen(lpszFileName.c_str(), _X("rb+"));
129129
if (NULL == pSt_File)
130130
{
131131
APIHelp_Port_Free(nPort);
@@ -193,7 +193,6 @@ static void XEngine_FTPUPload_Thread(xstring lpszClientAddr, xstring lpszFileNam
193193
Cryption_Api_Digest(lpszFileName.c_str(), tszHashStr, &nHashLen, true, st_ServiceCfg.st_XStorage.nHashMode);
194194
BaseLib_String_StrToHex((LPCXSTR)tszHashStr, nHashLen, st_ProtocolFile.st_ProtocolFile.tszFileHash);
195195

196-
_tcsxcpy(st_ProtocolFile.st_ProtocolFile.tszFileUser, st_ServiceCfg.st_XFtp.tszFTPDir);
197196
_tcsxcpy(st_ProtocolFile.tszBuckKey, st_ServiceCfg.st_XFtp.tszFTPDir);
198197
st_ProtocolFile.st_ProtocolFile.nFileSize = nllCount;
199198

@@ -204,7 +203,7 @@ static void XEngine_FTPUPload_Thread(xstring lpszClientAddr, xstring lpszFileNam
204203
{
205204
Database_File_FileInsert(&st_ProtocolFile, st_StorageBucket.st_PermissionFlags.bRewrite);
206205
}
207-
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("FTP客户端:%s 请求上传文件完毕, 插入数据库完毕,BucketName:%s,Table:%s,Path:%s%s,Hash:%s,Size:%lld"), lpszClientAddr.c_str(), st_ProtocolFile.tszBuckKey, st_ProtocolFile.tszTableName, st_ProtocolFile.st_ProtocolFile.tszFilePath, st_ProtocolFile.st_ProtocolFile.tszFileName, st_ProtocolFile.st_ProtocolFile.tszFileHash, st_ProtocolFile.st_ProtocolFile.nFileSize);
206+
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("FTP客户端:%s 请求上传文件完毕, 插入数据库完毕,BucketName:%s,Path:%s%s,Hash:%s,Size:%lld"), lpszClientAddr.c_str(), st_ProtocolFile.tszBuckKey, st_ProtocolFile.st_ProtocolFile.tszFilePath, st_ProtocolFile.st_ProtocolFile.tszFileName, st_ProtocolFile.st_ProtocolFile.tszFileHash, st_ProtocolFile.st_ProtocolFile.nFileSize);
208207
}
209208
//通知
210209
int nSDLen = 1024;
@@ -343,8 +342,16 @@ bool XEngine_Task_FTP(LPCXSTR lpszClientAddr, XENGINE_KEYVALUE *pSt_KeyValue, in
343342
return false;
344343
}
345344
}
346-
//转换
347-
Session_FTP_Set(lpszClientAddr, NULL, st_ServiceCfg.st_XFtp.tszFTPDir);
345+
//路径转换
346+
XENGINE_STORAGEBUCKET st_StorageBucket = {};
347+
if (!APIHelp_Distributed_CTStorage(st_ServiceCfg.st_XFtp.tszFTPDir, st_LoadbalanceCfg.st_LoadBalance.pStl_ListBucket, &st_StorageBucket))
348+
{
349+
FTPProtocol_Parse_SendPacketEx(xhFTPContral, XENGINE_FTPROTOCOL_RESPONSE_421, tszSDBuffer, &nSDLen);
350+
XEngine_Net_SendMsg(lpszClientAddr, tszSDBuffer, nSDLen, nNetType);
351+
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("FTP客户端:%s,请求登录失败,服务器配置错误,无法继续,错误:%lX"), lpszClientAddr, StorageHelp_GetLastError());
352+
return false;
353+
}
354+
Session_FTP_Set(lpszClientAddr, NULL, st_StorageBucket.tszFilePath);
348355
Session_FTP_SetUser(lpszClientAddr, NULL, pSt_KeyValue->tszStrVlu);
349356

350357
FTPProtocol_Parse_SendPacketEx(xhFTPContral, XENGINE_FTPROTOCOL_RESPONSE_230, tszSDBuffer, &nSDLen);

‎XEngine_Source/XEngine_StorageApp/XEngine_StorageApp.cpp‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -590,16 +590,6 @@ int main(int argc, char** argv)
590590

591591
APIHelp_Port_Init(st_ServiceCfg.st_XFtp.nFTPStart, st_ServiceCfg.st_XFtp.nFTPEnd);
592592
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,初始化FTP数据端口成功,端口范围:%d-%d"), st_ServiceCfg.st_XFtp.nFTPStart, st_ServiceCfg.st_XFtp.nFTPEnd);
593-
//路径转换
594-
XENGINE_STORAGEBUCKET st_StorageBucket = {};
595-
if (!APIHelp_Distributed_CTStorage(st_ServiceCfg.st_XFtp.tszFTPDir, st_LoadbalanceCfg.st_LoadBalance.pStl_ListBucket, &st_StorageBucket))
596-
{
597-
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("启动服务中,转换FTP路径失败,错误:%lX"), StorageHelp_GetLastError());
598-
goto XENGINE_EXITAPP;
599-
}
600-
memset(st_ServiceCfg.st_XFtp.tszFTPDir, '\0', sizeof(st_ServiceCfg.st_XFtp.tszFTPDir));
601-
_tcsxcpy(st_ServiceCfg.st_XFtp.tszFTPDir, st_StorageBucket.tszFileName);
602-
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,初始化FTP路径成功:%s -> %s"), st_ServiceCfg.st_XFtp.tszFTPDir, st_StorageBucket.tszFilePath);
603593
}
604594
//只有使用了数据库,才启用P2P
605595
if (st_ServiceCfg.st_P2xp.bEnable)

0 commit comments

Comments
 (0)