From a9ca2be90b9a927d16d5ae64c09cf664cc73536d Mon Sep 17 00:00:00 2001 From: edef Date: Thu, 28 Apr 2022 12:58:11 +0000 Subject: ripple/fossil: outline write_blob_inner Change-Id: I1c4a5d16cf10c464f9835c961481da221aa0d12e --- ripple/fossil/src/lib.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ripple/fossil/src/lib.rs b/ripple/fossil/src/lib.rs index b51fc27..3b2b3f8 100644 --- a/ripple/fossil/src/lib.rs +++ b/ripple/fossil/src/lib.rs @@ -116,11 +116,14 @@ impl Store { encoder.finalize().unwrap() }; - if self.blobs.contains_key(&*ident.as_bytes()).unwrap() { - // key already exists - return ident; + if !self.blobs.contains_key(&*ident.as_bytes()).unwrap() { + self.write_blob_inner(&ident, outboard, data); } + ident + } + + fn write_blob_inner(&self, ident: &Digest, outboard: Vec, data: &[u8]) { let mut chunks_file = self.chunks.borrow_mut(); let offset = self.chunks_tail.get(); @@ -149,8 +152,6 @@ impl Store { }) .unwrap(); self.chunks_tail.set(chunks_tail); - - ident.into() } pub fn read_blob(&self, ident: Digest) -> Vec { -- cgit 1.4.1