Skip to content

Commit c5729ed

Browse files
committed
fixed:The upload session is not processed correctly when there is only the length field
1 parent 3906c67 commit c5729ed

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

XEngine_Source/StorageModule_Session/Session_Stroage/Session_UPStroage.cpp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -128,23 +128,26 @@ BOOL CSession_UPStroage::Session_UPStroage_Insert(LPCTSTR lpszClientAddr, LPCTST
128128
_tcscpy(st_Client.st_StorageInfo.tszFileDir, lpszFileDir);
129129
_tcscpy(st_Client.st_StorageInfo.tszClientAddr, lpszClientAddr);
130130
//填充下载信息
131-
if (m_bResume)
131+
if ((m_bResume) && ((0 != nPosStart) || (0 != nPostEnd)))
132132
{
133133
st_Client.st_StorageInfo.pSt_File = _tfopen(lpszFileDir, _T("ab+"));
134+
if (NULL == st_Client.st_StorageInfo.pSt_File)
135+
{
136+
Session_IsErrorOccur = TRUE;
137+
Session_dwErrorCode = ERROR_STORAGE_MODULE_SESSION_OPENFILE;
138+
return FALSE;
139+
}
140+
fseek(st_Client.st_StorageInfo.pSt_File, nPosStart, SEEK_SET);
134141
}
135142
else
136143
{
137144
st_Client.st_StorageInfo.pSt_File = _tfopen(lpszFileDir, _T("wb"));
138-
}
139-
if (NULL == st_Client.st_StorageInfo.pSt_File)
140-
{
141-
Session_IsErrorOccur = TRUE;
142-
Session_dwErrorCode = ERROR_STORAGE_MODULE_SESSION_OPENFILE;
143-
return FALSE;
144-
}
145-
if (nPosStart > 0)
146-
{
147-
fseek(st_Client.st_StorageInfo.pSt_File, nPosStart, SEEK_SET);
145+
if (NULL == st_Client.st_StorageInfo.pSt_File)
146+
{
147+
Session_IsErrorOccur = TRUE;
148+
Session_dwErrorCode = ERROR_STORAGE_MODULE_SESSION_OPENFILE;
149+
return FALSE;
150+
}
148151
}
149152
st_Locker.lock();
150153
stl_MapStroage.insert(make_pair(lpszClientAddr, st_Client));

0 commit comments

Comments
 (0)