Пример #1
0
static dav_error *
_load_in_place_chunk_info(const dav_resource *r, const char *path, struct content_textinfo_s *content,
		struct chunk_textinfo_s *chunk, GHashTable **comp_opt)
{
	dav_error *e = NULL;
	GError *ge = NULL;
	apr_pool_t *p = r->pool;
	dav_rawx_server_conf *conf = resource_get_server_config(r);
	
	
	apr_finfo_t finfo;

	/* check chunk presence */

	if(APR_SUCCESS != apr_stat(&finfo, path, APR_FINFO_NORM, p)) {
		return server_create_and_stat_error(conf, r->pool, HTTP_NOT_FOUND,
				0, "Chunk file not found");
	}

	if(!get_rawx_info_in_attr(path, &ge,
				content, chunk)) {
		if(NULL != ge) {	
			e = server_create_and_stat_error(conf, p, HTTP_CONFLICT,
				0, apr_pstrcat(p, "Failed to get chunk attributes: ", ge->message, NULL));
			g_clear_error(&ge);
		} else {
			e = server_create_and_stat_error(conf, p, HTTP_CONFLICT,
			                                0, "Failed to get chunk chunk attributes: No error specified");
		}
		return e;
	}

	str_replace_by_pooled_str(p, &(content->path));
	str_replace_by_pooled_str(p, &(content->size));
	str_replace_by_pooled_str(p, &(content->chunk_nb));
	str_replace_by_pooled_str(p, &(content->metadata));
	str_replace_by_pooled_str(p, &(content->system_metadata));
	str_replace_by_pooled_str(p, &(content->container_id));
	str_replace_by_pooled_str(p, &(chunk->id));
	str_replace_by_pooled_str(p, &(chunk->path));
	str_replace_by_pooled_str(p, &(chunk->size));
	str_replace_by_pooled_str(p, &(chunk->hash));
	str_replace_by_pooled_str(p, &(chunk->position));
	str_replace_by_pooled_str(p, &(chunk->metadata));
	str_replace_by_pooled_str(p, &(chunk->container_id));

	if(!get_compression_info_in_attr(path, &ge, comp_opt)){
		if(NULL != ge) {	
			e = server_create_and_stat_error(conf, p, HTTP_CONFLICT,
				0, apr_pstrcat(p, "Failed to get chunk compression attributes: ", ge->message, NULL));
			g_clear_error(&ge);
		} else {
			e = server_create_and_stat_error(conf, p, HTTP_CONFLICT,
			                                0, "Failed to get chunk compression attributes: No error specified");
		}
		return e;
	}

	return NULL;
}
static dav_error *
_load_in_place_chunk_info(const dav_resource *r, const char *path, struct chunk_textinfo_s *chunk, GHashTable *comp_opt)
{
	dav_error *e = NULL;
	GError *ge = NULL;
	apr_pool_t *p = r->pool;
	dav_rawx_server_conf *conf = resource_get_server_config(r);

	/* No need to check for the chunk's presence, getting its attributes will
	 * fail if the chunk doesn't exists */
	if (!get_rawx_info_from_file(path, &ge, chunk)) {
		if (NULL != ge) {
			e = server_create_and_stat_error(conf, p, HTTP_CONFLICT, 0,
					apr_pstrcat(p, "Failed to get chunk attributes: ", ge->message, NULL));
			g_clear_error(&ge);
		} else {
			e = server_create_and_stat_error(conf, p, HTTP_CONFLICT, 0,
					"Failed to get chunk chunk attributes: No error specified");
		}
		return e;
	}

	str_replace_by_pooled_str(p, &(chunk->container_id));

	str_replace_by_pooled_str(p, &(chunk->content_id));
	str_replace_by_pooled_str(p, &(chunk->content_path));
	str_replace_by_pooled_str(p, &(chunk->content_version));
	str_replace_by_pooled_str(p, &(chunk->content_size));
	str_replace_by_pooled_str(p, &(chunk->content_chunk_nb));

	str_replace_by_pooled_str(p, &(chunk->content_storage_policy));
	str_replace_by_pooled_str(p, &(chunk->content_chunk_method));
	str_replace_by_pooled_str(p, &(chunk->content_mime_type));

	str_replace_by_pooled_str(p, &(chunk->chunk_id));
	str_replace_by_pooled_str(p, &(chunk->chunk_size));
	str_replace_by_pooled_str(p, &(chunk->chunk_position));
	str_replace_by_pooled_str(p, &(chunk->chunk_hash));

	if(!get_compression_info_in_attr(path, &ge, comp_opt)){
		if(NULL != ge) {
			e = server_create_and_stat_error(conf, p, HTTP_CONFLICT,
				0, apr_pstrcat(p, "Failed to get chunk compression attributes: ", ge->message, NULL));
			g_clear_error(&ge);
		} else {
			e = server_create_and_stat_error(conf, p, HTTP_CONFLICT,
			                                0, "Failed to get chunk compression attributes: No error specified");
		}
		return e;
	}

	return NULL;
}