Exemplo n.º 1
0
void checkChunkResponse(ds3_client* client, uint32_t num_files, ds3_get_available_chunks_response* chunk_response, checksum_result* results) {
    uint64_t max_file_index = 0;
    int64_t file_index = 0;
    ds3_request* request = NULL;
    ds3_error* error = NULL;

    for (uint64_t object_list_index = 0; object_list_index < chunk_response->object_list->list_size; object_list_index++) {
        ds3_bulk_object_list* chunk_object_list = chunk_response->object_list->list[object_list_index];
        for (uint64_t chunk_object_index = 0; chunk_object_index < chunk_object_list->size; chunk_object_index++) {
            FILE* w_file;
            ds3_bulk_object current_obj = chunk_object_list->list[chunk_object_index];
            file_index = getFileIndexForChunk(&max_file_index, current_obj.name, results);
            
            request = ds3_init_get_object_for_job(chunk_response->object_list->bucket_name->value, current_obj.name->value, current_obj.offset, chunk_response->object_list->job_id->value);
            
            w_file = fopen(results[file_index].tmp_name, "a+");
            fseek(w_file, current_obj.offset, SEEK_SET);
            
            error = ds3_get_object(client, request, w_file, ds3_write_to_file);
            ds3_free_request(request);
            fclose(w_file);
            handle_error(error);
        }
    }

    for (uint64_t current_file_index = 0; current_file_index < max_file_index; current_file_index++) {
        printf("------Performing Data Integrity Test-------\n");
        results[current_file_index].passed = compare_hash(results[current_file_index].original_name, results[current_file_index].tmp_name);
        unlink(results[current_file_index].tmp_name);
    }
}
Exemplo n.º 2
0
int main (void) {
    // Get Service
    ds3_client* client;
    ds3_request* request;
    ds3_error* error;
    ds3_get_service_response *response;
    uint64_t i;

    // Create a client from environment variables
    error = ds3_create_client_from_env(&client);
    handle_error(error);


    // Create the get service request.  All requests to a DS3 appliance start this way.
    // All ds3_init_* functions return a ds3_request struct
    request = ds3_init_get_service();

    // This performs the request to a DS3 appliance.
    // If there is an error 'error' will not be NULL
    // If the request completed successfully then 'error' will be NULL
    error = ds3_get_service(client, request, &response);
    ds3_free_request(request);

    handle_error(error);

    if(response->num_buckets == 0) {
        printf("No buckets returned\n");
        ds3_free_service_response(response);
        ds3_free_creds(client->creds);
        ds3_free_client(client);
        return 0;
    }

    for (i = 0; i < response->num_buckets; i++) {
        ds3_bucket bucket = response->buckets[i];
        printf("Bucket: (%s) created on %s\n", bucket.name->value, bucket.creation_date->value);
    }

    ds3_free_service_response(response);
    ds3_free_creds(client->creds);
    ds3_free_client(client);
    ds3_cleanup();

    return 0;
}