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 gboolean copy_fattr(const gchar *src, gchar* dst, GError **error) { gboolean status = FALSE; struct content_textinfo_s *content = NULL; struct chunk_textinfo_s *chunk = NULL; content = g_malloc0(sizeof(struct content_textinfo_s)); chunk = g_malloc0(sizeof(struct chunk_textinfo_s)); if(!get_rawx_info_in_attr(src, error, content, chunk)) { GSETERROR(error, "Failed to load extended attributes from source file\n"); goto err; } /*Check we are working with a gs chunk */ if(!chunk->id) { GSETERROR(error, "No chunk_id found in source file extended attributes, may be this file is not a chunk\n"); goto err; } if(!set_rawx_info_in_attr(dst, error, content, chunk)) { GSETERROR(error, "Failed to set extended attributes to destination file\n"); goto err; } status = TRUE; err: if(chunk) { chunk_textinfo_free_content(chunk); g_free(chunk); } if(content) { content_textinfo_free_content(content); g_free(content); } return status; }
gboolean get_chunk_info_in_attr(const char *p, GError **e, struct chunk_textinfo_s *c) { return get_rawx_info_in_attr (p, e, NULL, c); }
gboolean get_content_info_in_attr(const char *p, GError **e, struct content_textinfo_s *c) { return get_rawx_info_in_attr (p, e, c, NULL); }