mirror of https://github.com/zkat/cacache-rs.git
fix(check): {Async}Get::check wasn't working correctly
This commit is contained in:
parent
398773547b
commit
d08629cf55
|
|
@ -18,7 +18,7 @@ pub struct Reader {
|
|||
impl std::io::Read for Reader {
|
||||
fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
|
||||
let amt = self.fd.read(buf)?;
|
||||
self.checker.input(&buf);
|
||||
self.checker.input(&buf[..amt]);
|
||||
Ok(amt)
|
||||
}
|
||||
}
|
||||
|
|
@ -41,7 +41,7 @@ impl AsyncRead for AsyncReader {
|
|||
buf: &mut [u8],
|
||||
) -> Poll<std::io::Result<usize>> {
|
||||
let amt = futures::ready!(Pin::new(&mut self.fd).poll_read(cx, buf))?;
|
||||
self.checker.input(&buf);
|
||||
self.checker.input(&buf[..amt]);
|
||||
Poll::Ready(Ok(amt))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
12
src/get.rs
12
src/get.rs
|
|
@ -56,6 +56,8 @@ impl AsyncGet {
|
|||
/// let mut handle = cacache::get::open("./my-cache", "my-key").await?;
|
||||
/// let mut str = String::new();
|
||||
/// handle.read_to_string(&mut str).await?;
|
||||
/// // Remember to check that the data you got was correct!
|
||||
/// handle.check()?;
|
||||
/// # Ok(())
|
||||
/// # }
|
||||
/// ```
|
||||
|
|
@ -89,6 +91,8 @@ where
|
|||
/// let mut handle = cacache::get::open_hash("./my-cache", sri).await?;
|
||||
/// let mut str = String::new();
|
||||
/// handle.read_to_string(&mut str).await?;
|
||||
/// // Remember to check that the data you got was correct!
|
||||
/// handle.check()?;
|
||||
/// # Ok(())
|
||||
/// # }
|
||||
/// ```
|
||||
|
|
@ -197,6 +201,8 @@ impl Get {
|
|||
/// let mut handle = cacache::get::open_sync("./my-cache", "my-key")?;
|
||||
/// let mut str = String::new();
|
||||
/// handle.read_to_string(&mut str)?;
|
||||
/// // Remember to check that the data you got was correct!
|
||||
/// handle.check()?;
|
||||
/// # Ok(())
|
||||
/// # }
|
||||
/// ```
|
||||
|
|
@ -222,6 +228,8 @@ where
|
|||
/// let mut handle = cacache::get::open_hash_sync("./my-cache", sri)?;
|
||||
/// let mut str = String::new();
|
||||
/// handle.read_to_string(&mut str)?;
|
||||
/// // Remember to check that the data you got was correct!
|
||||
/// handle.check()?;
|
||||
/// # Ok(())
|
||||
/// # }
|
||||
/// ```
|
||||
|
|
@ -312,6 +320,7 @@ mod tests {
|
|||
let mut handle = crate::get::open(&dir, "my-key").await.unwrap();
|
||||
let mut str = String::new();
|
||||
handle.read_to_string(&mut str).await.unwrap();
|
||||
handle.check().unwrap();
|
||||
assert_eq!(str, String::from("hello world"));
|
||||
})
|
||||
}
|
||||
|
|
@ -328,6 +337,7 @@ mod tests {
|
|||
let mut handle = crate::get::open_hash(&dir, sri).await.unwrap();
|
||||
let mut str = String::new();
|
||||
handle.read_to_string(&mut str).await.unwrap();
|
||||
handle.check().unwrap();
|
||||
assert_eq!(str, String::from("hello world"));
|
||||
})
|
||||
}
|
||||
|
|
@ -342,6 +352,7 @@ mod tests {
|
|||
let mut handle = crate::get::open_sync(&dir, "my-key").unwrap();
|
||||
let mut str = String::new();
|
||||
handle.read_to_string(&mut str).unwrap();
|
||||
handle.check().unwrap();
|
||||
assert_eq!(str, String::from("hello world"));
|
||||
}
|
||||
|
||||
|
|
@ -355,6 +366,7 @@ mod tests {
|
|||
let mut handle = crate::get::open_hash_sync(&dir, sri).unwrap();
|
||||
let mut str = String::new();
|
||||
handle.read_to_string(&mut str).unwrap();
|
||||
handle.check().unwrap();
|
||||
assert_eq!(str, String::from("hello world"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue