mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-01-03 09:58:13 +01:00
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:
@@ -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}),
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// This file was generated automatically from 'src/mako/lib.rs.mako'
|
||||
// DO NOT EDIT !
|
||||
|
||||
//! This documentation was generated from *taskqueue* crate version *0.1.0+20141111*, where *20141111* is the exact revision of the *taskqueue:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.0*.
|
||||
//! This documentation was generated from *taskqueue* crate version *0.1.1+20141111*, where *20141111* is the exact revision of the *taskqueue:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.1*.
|
||||
//!
|
||||
//! Everything else about the *taskqueue* *v1_beta2* API can be found at the
|
||||
//! [official documentation site](https://developers.google.com/appengine/docs/python/taskqueue/rest).
|
||||
@@ -303,7 +303,7 @@ impl<'a, C, NC, A> Taskqueue<C, NC, A>
|
||||
Taskqueue {
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -316,7 +316,7 @@ impl<'a, C, NC, A> Taskqueue<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 {
|
||||
|
||||
Reference in New Issue
Block a user