fix(mbuild): upload size now taken properly

Previously, it would query the size from the wrong dict and obtain
the value 0 all the time. This would have made every upload fail with
`UploadSizeLimitExeeded`.
Now we obtain the actual size limit, and will ignore it if unset/0
for some reason.

Patch += 1
This commit is contained in:
Sebastian Thiel
2015-03-22 22:39:13 +01:00
parent 3bc930ae47
commit 04f4c95688
287 changed files with 1134 additions and 1648 deletions

View File

@@ -4,7 +4,7 @@
[package]
name = "google-storage1"
version = "0.1.0+20150213"
version = "0.1.1+20150213"
authors = ["Sebastian Thiel <byronimo@gmail>"]
description = "A complete library to interact with storage (protocol v1)"
repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/storage1"

View File

@@ -5,7 +5,7 @@ DO NOT EDIT !
-->
The `google-storage1` library allows access to all features of the *Google storage* service.
This documentation was generated from *storage* crate version *0.1.0+20150213*, where *20150213* is the exact revision of the *storage:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.0*.
This documentation was generated from *storage* crate version *0.1.1+20150213*, where *20150213* is the exact revision of the *storage:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.1*.
Everything else about the *storage* *v1* API can be found at the
[official documentation site](https://developers.google.com/storage/docs/json_api/).

View File

@@ -274,6 +274,7 @@ impl<'a> MultiPartReader<'a> {
/// Add a new part to the queue of parts to be read on the first `read` call.
///
/// # Arguments
///
/// `headers` - identifying the body of the part. It's similar to the header
/// in an ordinary single-part call, and should thus contain the
/// same information.
@@ -281,9 +282,6 @@ impl<'a> MultiPartReader<'a> {
/// `size` - the amount of bytes provided by the reader. It will be put onto the header as
/// content-size.
/// `mime` - It will be put onto the content type
/// # Panics
///
/// If this method is called after the first `read` call, it will panic
pub fn add_part(&mut self, reader: &'a mut Read, size: u64, mime_type: Mime) -> &mut MultiPartReader<'a> {
let mut headers = Headers::new();
headers.set(ContentType(mime_type));
@@ -462,22 +460,17 @@ impl Header for RangeResponseHeader {
}
fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> {
match raw {
[ref v] => {
if let Ok(s) = std::str::from_utf8(v) {
const PREFIX: &'static str = "bytes=";
if s.starts_with(PREFIX) {
let c: Chunk = match FromStr::from_str(&s[PREFIX.len()..]) {
Ok(c) => c,
_ => return None
};
if let [ref v] = raw {
if let Ok(s) = std::str::from_utf8(v) {
const PREFIX: &'static str = "bytes=";
if s.starts_with(PREFIX) {
if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) {
return Some(RangeResponseHeader(c))
}
}
None
},
_ => None
}
}
None
}
}
@@ -557,13 +550,13 @@ impl<'a, NC, A> ResumableUploadHelper<'a, NC, A>
_ => MIN_CHUNK_SIZE
};
self.reader.seek(SeekFrom::Start(start)).unwrap();
loop {
let request_size = match self.content_length - start {
rs if rs > chunk_size => chunk_size,
rs => rs
};
self.reader.seek(SeekFrom::Start(start)).unwrap();
let mut section_reader = self.reader.take(request_size);
let range_header = ContentRange {
range: Some(Chunk {first: start, last: start + request_size - 1}),

View File

@@ -2,7 +2,7 @@
// This file was generated automatically from 'src/mako/lib.rs.mako'
// DO NOT EDIT !
//! This documentation was generated from *storage* crate version *0.1.0+20150213*, where *20150213* is the exact revision of the *storage:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.0*.
//! This documentation was generated from *storage* crate version *0.1.1+20150213*, where *20150213* is the exact revision of the *storage:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.1*.
//!
//! Everything else about the *storage* *v1* API can be found at the
//! [official documentation site](https://developers.google.com/storage/docs/json_api/).
@@ -349,7 +349,7 @@ impl<'a, C, NC, A> Storage<C, NC, A>
Storage {
client: RefCell::new(client),
auth: RefCell::new(authenticator),
_user_agent: "google-api-rust-client/0.1.0".to_string(),
_user_agent: "google-api-rust-client/0.1.1".to_string(),
_m: PhantomData
}
}
@@ -374,7 +374,7 @@ impl<'a, C, NC, A> Storage<C, NC, A>
}
/// Set the user-agent header field to use in all requests to the server.
/// It defaults to `google-api-rust-client/0.1.0`.
/// It defaults to `google-api-rust-client/0.1.1`.
///
/// Returns the previously set user-agent.
pub fn user_agent(&mut self, agent_name: String) -> String {
@@ -6408,9 +6408,7 @@ impl<'a, C, NC, A> ObjectInsertCall<'a, C, NC, A> where NC: hyper::net::NetworkC
mp_reader.reserve_exact(2);
let size = reader.seek(io::SeekFrom::End(0)).unwrap();
reader.seek(io::SeekFrom::Start(0)).unwrap();
if size > 0 {
return Result::UploadSizeLimitExceeded(size, 0)
}
mp_reader.add_part(&mut request_value_reader, request_size, json_mime_type.clone())
.add_part(&mut reader, size, reader_mime_type.clone());
let mime_type = mp_reader.mime_type();
@@ -6458,9 +6456,7 @@ impl<'a, C, NC, A> ObjectInsertCall<'a, C, NC, A> where NC: hyper::net::NetworkC
if protocol == "resumable" {
let size = reader.seek(io::SeekFrom::End(0)).unwrap();
reader.seek(io::SeekFrom::Start(0)).unwrap();
if size > 0 {
return Result::UploadSizeLimitExceeded(size, 0)
}
let mut client = &mut *self.hub.client.borrow_mut();
let upload_result = {
let url = &res.headers.get::<Location>().expect("Location header is part of protocol").0;