Skip to content

Commit

Permalink
Update fallback.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
DouglasDwyer authored and cberner committed Dec 8, 2023
1 parent e5cf573 commit 9c28085
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/tree_store/page_store/file_backend/fallback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ pub struct FileBackend {
impl FileBackend {
/// Creates a new backend which stores data to the given file.
pub fn new(file: File) -> Result<Self, DatabaseError> {
Self {
Ok(Self {
file: Mutex::new(file),
}
})
}
}

Expand All @@ -26,7 +26,7 @@ impl StorageBackend for FileBackend {

fn read(&self, offset: u64, len: usize) -> Result<Vec<u8>, io::Error> {
let mut result = vec![0; len];
let file = self.file.lock().unwrap();
let mut file = self.file.lock().unwrap();
file.seek(SeekFrom::Start(offset))?;
file.read_exact(&mut result)?;
Ok(result)
Expand All @@ -41,7 +41,7 @@ impl StorageBackend for FileBackend {
}

fn write(&self, offset: u64, data: &[u8]) -> Result<(), io::Error> {
let file = self.file.lock().unwrap();
let mut file = self.file.lock().unwrap();
file.seek(SeekFrom::Start(offset))?;
file.write_all(data)
}
Expand Down

0 comments on commit 9c28085

Please sign in to comment.