From 4bacaaf53f14ab9340795a5aa98124816d2dab9b Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Fri, 17 Apr 2020 18:38:11 +0200 Subject: Resync block on read error --- src/block.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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); -- cgit v1.2.3