aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2020-04-17 18:38:11 +0200
committerAlex Auvolat <alex@adnab.me>2020-04-17 18:38:11 +0200
commit4bacaaf53f14ab9340795a5aa98124816d2dab9b (patch)
treee259178a1c8bf4a896c63c9bb47d07cd2b1ed352
parentb780f6485ddf385b584f02b3b17b859b6c432eb9 (diff)
downloadgarage-4bacaaf53f14ab9340795a5aa98124816d2dab9b.tar.gz
garage-4bacaaf53f14ab9340795a5aa98124816d2dab9b.zip
Resync block on read error
-rw-r--r--src/block.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/block.rs b/src/block.rs
index 25a10910..4be8df37 100644
--- a/src/block.rs
+++ b/src/block.rs
@@ -77,7 +77,14 @@ impl BlockManager {
let mut path = self.block_dir(hash);
path.push(hex::encode(hash));
- let mut f = fs::File::open(&path).await?;
+ let mut f = match fs::File::open(&path).await {
+ Ok(f) => f,
+ Err(e) => {
+ // Not found but maybe we should have had it ??
+ self.put_to_resync(hash, DEFAULT_TIMEOUT.as_millis() as u64)?;
+ return Err(Into::into(e));
+ }
+ };
let mut data = vec![];
f.read_to_end(&mut data).await?;
drop(f);