void cloud_blob_properties::update_all(const cloud_blob_properties& parsed_properties, bool ignore_md5) { if ((type() != blob_type::unspecified) && (type() != parsed_properties.type())) { throw storage_exception(protocol::error_blob_type_mismatch, false); } utility::string_t content_md5(ignore_md5 ? m_content_md5 : parsed_properties.content_md5()); *this = parsed_properties; m_content_md5 = content_md5; }
static void do_header(struct rfc2045 *p) { struct rfc822t *header; char *t; if (p->headerlen == 0) return; rfc2045_add_buf( &p->header, &p->headersize, &p->headerlen, "", 1); /* 0 terminate */ /* Parse the header line according to RFC822 */ header=rfc822t_alloc_new(p->header, NULL, NULL); if (!header) return; /* Broken header */ if (header->ntokens < 2 || header->tokens[0].token || header->tokens[1].token != ':') { rfc822t_free(header); return; /* Broken header */ } t=lower_paste_token(header, 0); if (t == 0) ; else if (strcmp(t, "mime-version") == 0) { free(t); mime_version(p, header); } else if (strcmp(t, "content-type") == 0) { free(t); content_type(p, header); } else if (strcmp(t, "content-transfer-encoding") == 0) { free(t); content_transfer_encoding(p, header); } else if (strcmp(t, "content-disposition") == 0) { free(t); content_disposition(p, header); } else if (strcmp(t, "content-id") == 0) { free(t); content_id(p, header); } else if (strcmp(t, "content-description") == 0) { free(t); t=strchr(p->header, ':'); if (t) ++t; while (t && isspace((int)(unsigned char)*t)) ++t; content_description(p, t); } else if (strcmp(t, "content-language") == 0) { free(t); t=strchr(p->header, ':'); if (t) ++t; while (t && isspace((int)(unsigned char)*t)) ++t; content_language(p, t); } else if (strcmp(t, "content-base") == 0) { free(t); content_base(p, header); } else if (strcmp(t, "content-location") == 0) { free(t); content_location(p, header); } else if (strcmp(t, "content-md5") == 0) { free(t); t=strchr(p->header, ':'); if (t) ++t; while (t && isspace((int)(unsigned char)*t)) ++t; content_md5(p, t); } else free(t); rfc822t_free(header); }
pplx::task<void> basic_cloud_page_blob_ostreambuf::upload_buffer() { auto buffer = prepare_buffer(); if (buffer->is_empty()) { return pplx::task_from_result(); } auto offset = m_current_blob_offset; m_current_blob_offset += buffer->size(); auto this_pointer = std::dynamic_pointer_cast<basic_cloud_page_blob_ostreambuf>(shared_from_this()); return m_semaphore.lock_async().then([this_pointer, buffer, offset] () { if (this_pointer->m_currentException == nullptr) { try { this_pointer->m_blob->upload_pages_async(buffer->stream(), offset, buffer->content_md5(), this_pointer->m_condition, this_pointer->m_options, this_pointer->m_context).then([this_pointer] (pplx::task<void> upload_task) { std::lock_guard<async_semaphore> guard(this_pointer->m_semaphore, std::adopt_lock); try { upload_task.wait(); } catch (const std::exception&) { this_pointer->m_currentException = std::current_exception(); } }); } catch (...) { this_pointer->m_semaphore.unlock(); } } else { this_pointer->m_semaphore.unlock(); } }); }