diff options
author | Alex Auvolat <alex@adnab.me> | 2020-04-10 22:01:48 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2020-04-10 22:01:48 +0200 |
commit | 3477864142ed09c36abea1111937b829fb41c8a4 (patch) | |
tree | d95221e66b9c014af7f4dba61ae4ff113c0e409a /src/block.rs | |
parent | d66c0d6833ddbeb61e34ee222dde92a5363bda1f (diff) | |
download | garage-3477864142ed09c36abea1111937b829fb41c8a4.tar.gz garage-3477864142ed09c36abea1111937b829fb41c8a4.zip |
Fix the Sync issue. Details:
So the HTTP client future of Hyper is not Sync, thus the stream
that read blocks wasn't either. However Hyper's default Body type
requires a stream to be Sync for wrap_stream. Solution: reimplement
a custom HTTP body type.
Diffstat (limited to 'src/block.rs')
-rw-r--r-- | src/block.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/block.rs b/src/block.rs index b9e7eee8..99a0121f 100644 --- a/src/block.rs +++ b/src/block.rs @@ -1,13 +1,13 @@ -use std::sync::Arc; use std::path::PathBuf; +use std::sync::Arc; use tokio::fs; use tokio::prelude::*; +use crate::data::*; use crate::error::Error; -use crate::server::Garage; use crate::proto::*; -use crate::data::*; +use crate::server::Garage; fn block_dir(garage: &Garage, hash: &Hash) -> PathBuf { let mut path = garage.system.config.data_dir.clone(); @@ -24,7 +24,7 @@ pub async fn write_block(garage: Arc<Garage>, hash: &Hash, data: &[u8]) -> Resul path.push(hex::encode(hash)); if fs::metadata(&path).await.is_ok() { - return Ok(Message::Ok) + return Ok(Message::Ok); } let mut f = fs::File::create(path).await?; @@ -42,7 +42,7 @@ pub async fn read_block(garage: Arc<Garage>, hash: &Hash) -> Result<Message, Err let mut data = vec![]; f.read_to_end(&mut data).await?; - Ok(Message::PutBlock(PutBlockMessage{ + Ok(Message::PutBlock(PutBlockMessage { hash: hash.clone(), data, })) |