예제 #1
0
static void delete_all_buckets(DS_Bucket_t **buckets, size_t amount_of_buckets, DS_delete_cb del){
	size_t i = 0;
	DS_Bucket_t *curr_bucket = NULL, *head_bucket = NULL;
	for(; i < amount_of_buckets; i++){
		if(!(head_bucket = curr_bucket = buckets[i])){
			continue;
		}
		while((head_bucket = curr_bucket->next)){
			delete_bucket(curr_bucket, del);
			curr_bucket = head_bucket;
		}
		if(curr_bucket){
			delete_bucket(curr_bucket, del);
		}
	}
}
예제 #2
0
void TEST_COPY_OBJECT_WITH_SRC_BUCKET_NOT_EXIST() {
    int error;
    buffer* resp = NULL;

    const char* src_bucket_not_exist = "src-bucket-not-exist";
    const char* src_obj_key = "unit_test_dir/src_object1";

    // delete src bucket
    resp = delete_bucket(host, src_bucket_not_exist, ak, sk, NULL, &error);
    CU_ASSERT(0 == error);
    CU_ASSERT(404 == resp->status_code);
    buffer_free(resp);

    // copy obj
    const char* dst_obj_key = src_obj_key;
    resp = copy_object(host, src_bucket_not_exist, src_obj_key,
            dst_bucket, dst_obj_key, ak, sk, NULL, NULL, &error);
    CU_ASSERT(0 == error);
    CU_ASSERT(404 == resp->status_code);
    if (404 != resp->status_code) {
        printf("status code = %ld\n", resp->status_code);
        printf("status msg = %s\n", resp->status_msg);
        printf("error msg = %s\n", resp->body);
    }
    buffer_free(resp);
}
예제 #3
0
파일: hash.c 프로젝트: frmendes/uminho
static void delete_bucket(bucket b) {
    if(!b)
        return;
    delete_hash(b -> subnodes);
    delete_bucket(b -> next);
    free(b -> key);
    free(b);
}
예제 #4
0
파일: hash.c 프로젝트: frmendes/uminho
void delete_hash(hash h) {
    if(!h)
        return;

    for(int i = 0; i < h -> n_elements; i++)
        delete_bucket(h -> table[i]);

    free(h);
}
예제 #5
0
void TEST_COPY_OBJECT_WITH_DST_BUCKET_NOT_EXIST() {
    int error;
    buffer* resp = NULL;

    const char* src_obj_key = "unit_test_dir/src_object1";
    const char* filename = "./lib/libcunit.a";

    // upload first
    resp = delete_object(host, src_bucket, src_obj_key, ak, sk, NULL, &error);
    CU_ASSERT(0 == error);
    CU_ASSERT(204 == resp->status_code || 404 == resp->status_code);
    buffer_free(resp);

    resp = upload_file_object(host, src_bucket, src_obj_key, filename,
            ak, sk, NULL, NULL, &error);
    CU_ASSERT(0 == error);
    CU_ASSERT(200 == resp->status_code);
    buffer_free(resp);

    // copy obj
    const char* dst_bucket_not_exist = "dst-bucket-not-exist";
    const char* dst_obj_key = src_obj_key;

    resp = delete_bucket(host, dst_bucket_not_exist, ak, sk, NULL, &error);
    CU_ASSERT(0 == error);
    CU_ASSERT(404 == resp->status_code);
    buffer_free(resp);

    resp = copy_object(host, src_bucket, src_obj_key,
            dst_bucket_not_exist, dst_obj_key, ak, sk, NULL, NULL, &error);
    CU_ASSERT(0 == error);
    CU_ASSERT(404 == resp->status_code);
    if (404 != resp->status_code) {
        printf("status code = %ld\n", resp->status_code);
        printf("status msg = %s\n", resp->status_msg);
        printf("error msg = %s\n", resp->body);
    }
    buffer_free(resp);

    // delete src obj
    resp = delete_object(host, src_bucket, src_obj_key, ak, sk, NULL, &error);
    CU_ASSERT(0 == error);
    CU_ASSERT(204 == resp->status_code);
    buffer_free(resp);
}
예제 #6
0
int main(int argc, char *argv[]) {
    oss_media_init(AOS_LOG_INFO);
    
    if (argc < 2) {
        usage();
        oss_media_destroy();
        return -1;
    }

    if (strcmp("create_bucket", argv[1]) == 0) {
        create_bucket();
    }
    else if (strcmp("delete_bucket", argv[1]) == 0) {
        delete_bucket();
    }
    else if (strcmp("delete_file", argv[1]) == 0) {
        delete_file();
    }
    else if (strcmp("list_files", argv[1]) == 0) {
        list_files();
    }
    else if (strcmp("create_bucket_lifecycle", argv[1]) == 0) {
        create_bucket_lifecycle();
    }
    else if (strcmp("get_bucket_lifecycle", argv[1]) == 0) {
        get_bucket_lifecycle();
    }
    else if (strcmp("delete_bucket_lifecycle", argv[1]) == 0) {
        delete_bucket_lifecycle();
    }
    else if (strcmp("get_token", argv[1]) == 0) {
        get_token();
    }
    else if (strcmp("get_token_from_policy", argv[1]) == 0) {
        get_token_from_policy();
    } 
    else {
        printf("Unsupport operation: %s\n", argv[1]);
        usage();
    }

    oss_media_destroy();
    
    return 0;
}