Merge pull request #27392 from taosdata/fix/TD-31569/setDelFileOnWindows

Fix/td 31569/set del file on windows
This commit is contained in:
dapan1121 2024-08-22 14:41:03 +08:00 committed by GitHub
commit ed9666595c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 2 deletions

View File

@ -1350,7 +1350,7 @@ static int32_t createSortMemFile(SSortHandle* pHandle) {
}
if (code == TSDB_CODE_SUCCESS) {
taosGetTmpfilePath(tsTempDir, "sort-ext-mem", pMemFile->memFilePath);
pMemFile->pTdFile = taosOpenCFile(pMemFile->memFilePath, "w+");
pMemFile->pTdFile = taosOpenCFile(pMemFile->memFilePath, "w+b");
if (pMemFile->pTdFile == NULL) {
code = terrno = TAOS_SYSTEM_ERROR(errno);
}

View File

@ -1633,7 +1633,14 @@ int taosCloseCFile(FILE *f) { return fclose(f); }
int taosSetAutoDelFile(char *path) {
#ifdef WINDOWS
return SetFileAttributes(path, FILE_ATTRIBUTE_TEMPORARY);
bool succ = SetFileAttributes(path, FILE_ATTRIBUTE_TEMPORARY);
if (succ) {
return 0;
} else {
DWORD error = GetLastError();
terrno = TAOS_SYSTEM_ERROR(error);
return terrno;
}
#else
if (-1 == unlink(path)) {
terrno = TAOS_SYSTEM_ERROR(errno);