From 72cf550c9f2cf76d426bca78d39e02ff089a7abc Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 29 Jan 2016 18:17:41 +0100 Subject: [PATCH] Fix: seek() file back on reading it --- libimagstore/src/store.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libimagstore/src/store.rs b/libimagstore/src/store.rs index 621be544..e7a4a3df 100644 --- a/libimagstore/src/store.rs +++ b/libimagstore/src/store.rs @@ -7,7 +7,7 @@ use std::sync::Arc; use std::sync::RwLock; use std::error::Error; use std::collections::BTreeMap; - +use std::io::{Seek, SeekFrom}; use fs2::FileExt; use toml::{Table, Value}; @@ -63,7 +63,10 @@ impl StoreEntry { } } else { // TODO: - Entry::from_file(self.id.clone(), file.unwrap()) + let mut file = file.unwrap(); + let entry = Entry::from_file(self.id.clone(), &mut file); + file.seek(SeekFrom::Start(0)); + entry } } else { return Err(StoreError::new(StoreErrorKind::EntryAlreadyBorrowed, None))