prefix/delete: delete with prefix
This commit is contained in:
parent
4a77a49a3e
commit
2479bb343e
|
@ -191,7 +191,7 @@ if(${BUILD_WITH_S3})
|
|||
#cat("${TD_SUPPORT_DIR}/curl_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||
#INCLUDE_DIRECTORIES($ENV{HOME}/.cos-local.1/include)
|
||||
|
||||
cat("${TD_SUPPORT_DIR}/ssl_CMakeLists.txt.in" ${CONTRIB_TMP_FILE3})
|
||||
cat("${TD_SUPPORT_DIR}/ssl_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||
cat("${TD_SUPPORT_DIR}/xml2_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||
cat("${TD_SUPPORT_DIR}/curl_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||
cat("${TD_SUPPORT_DIR}/libs3_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||
|
|
|
@ -123,6 +123,7 @@ typedef struct list_bucket_callback_data {
|
|||
char nextMarker[1024];
|
||||
int keyCount;
|
||||
int allDetails;
|
||||
SArray *objectArray;
|
||||
S3Status status;
|
||||
char err_msg[4096];
|
||||
} list_bucket_callback_data;
|
||||
|
@ -149,7 +150,9 @@ static S3Status listBucketCallback(int isTruncated, const char *nextMarker, int
|
|||
int i;
|
||||
for (i = 0; i < contentsCount; ++i) {
|
||||
const S3ListBucketContent *content = &(contents[i]);
|
||||
printf("%-50s", content->key);
|
||||
// printf("%-50s", content->key);
|
||||
char *object_key = strdup(content->key);
|
||||
taosArrayPush(data->objectArray, &object_key);
|
||||
}
|
||||
data->keyCount += contentsCount;
|
||||
|
||||
|
@ -160,6 +163,11 @@ static S3Status listBucketCallback(int isTruncated, const char *nextMarker, int
|
|||
return S3StatusOK;
|
||||
}
|
||||
|
||||
static void s3FreeObjectKey(void *pItem) {
|
||||
char *key = (char *)pItem;
|
||||
taosMemoryFree(key);
|
||||
}
|
||||
|
||||
void s3DeleteObjectsByPrefix(const char *prefix) {
|
||||
S3BucketContext bucketContext = {0, tsS3BucketName, protocolG, uriStyleG, tsS3AccessKeyId, tsS3AccessKeySecret,
|
||||
0, awsRegionG};
|
||||
|
@ -169,7 +177,11 @@ void s3DeleteObjectsByPrefix(const char *prefix) {
|
|||
const char *marker = 0, *delimiter = 0;
|
||||
int maxkeys = 0, allDetails = 0;
|
||||
list_bucket_callback_data data;
|
||||
|
||||
data.objectArray = taosArrayInit(32, POINTER_BYTES);
|
||||
if (!data.objectArray) {
|
||||
vError("%s: %s", __func__, "out of memoty");
|
||||
return;
|
||||
}
|
||||
if (marker) {
|
||||
snprintf(data.nextMarker, sizeof(data.nextMarker), "%s", marker);
|
||||
} else {
|
||||
|
@ -192,10 +204,13 @@ void s3DeleteObjectsByPrefix(const char *prefix) {
|
|||
if (data.status == S3StatusOK) {
|
||||
if (!data.keyCount) {
|
||||
// printListBucketHeader(allDetails);
|
||||
s3DeleteObjects(TARRAY_DATA(data.objectArray), TARRAY_SIZE(data.objectArray));
|
||||
}
|
||||
} else {
|
||||
s3PrintError(__func__, data.status, data.err_msg);
|
||||
}
|
||||
|
||||
taosArrayDestroyEx(data.objectArray, s3FreeObjectKey);
|
||||
}
|
||||
|
||||
void s3DeleteObjects(const char *object_name[], int nobject) {
|
||||
|
|
Loading…
Reference in New Issue