diff --git a/include/os/osDef.h b/include/os/osDef.h index bad4536fa6..1a831f2e86 100644 --- a/include/os/osDef.h +++ b/include/os/osDef.h @@ -237,6 +237,12 @@ void syslog(int unused, const char *format, ...); #define TD_DIRSEP "/" #endif +#if defined(_WIN32) +#define TD_DIRSEP_CHAR '\\' +#else +#define TD_DIRSEP_CHAR '/' +#endif + #define TD_LOCALE_LEN 64 #define TD_CHARSET_LEN 64 #define TD_TIMEZONE_LEN 96 diff --git a/source/common/src/cos.c b/source/common/src/cos.c index 4b079a17cb..423b7c1243 100644 --- a/source/common/src/cos.c +++ b/source/common/src/cos.c @@ -825,8 +825,8 @@ int32_t s3GetObjectsByPrefix(const char *prefix, const char* path){ const char* tmp = strchr(object, '/'); tmp = (tmp == NULL) ? object : tmp + 1; char fileName[PATH_MAX] = {0}; - if(path[strlen(path) - 1] != '/'){ - snprintf(fileName, PATH_MAX, "%s/%s", path, tmp); + if(path[strlen(path) - 1] != TD_DIRSEP_CHAR){ + snprintf(fileName, PATH_MAX, "%s%s%s", path, TD_DIRSEP, tmp); }else{ snprintf(fileName, PATH_MAX, "%s%s", path, tmp); } diff --git a/source/libs/stream/src/streamCheckpoint.c b/source/libs/stream/src/streamCheckpoint.c index c3152aebb7..b4a9dd3b43 100644 --- a/source/libs/stream/src/streamCheckpoint.c +++ b/source/libs/stream/src/streamCheckpoint.c @@ -478,7 +478,7 @@ static int uploadCheckpointToS3(char* id, char* path){ taosDirEntryIsDir(de)) continue; char filename[PATH_MAX] = {0}; - if(path[strlen(path - 1)] == '/'){ + if(path[strlen(path - 1)] == TD_DIRSEP_CHAR){ snprintf(filename, sizeof(filename), "%s%s", path, name); }else{ snprintf(filename, sizeof(filename), "%s%s%s", path, TD_DIRSEP, name); @@ -491,6 +491,7 @@ static int uploadCheckpointToS3(char* id, char* path){ taosCloseDir(&pDir); return -1; } + stDebug("[s3] upload checkpoint:%s", filename); } taosCloseDir(&pDir); @@ -548,7 +549,7 @@ int deleteCheckpoint(char* id){ int deleteCheckpointFile(char* id, char* name){ char object[128] = {0}; - snprintf(object, sizeof(object), "%s%s%s", id, TD_DIRSEP, name); + snprintf(object, sizeof(object), "%s/%s", id, name); char *tmp = object; s3DeleteObjects((const char**)&tmp, 1); return 0;