Clean exit when no space left on device (#6339)

Fixes #6305
This commit is contained in:
Cecile Tonglet
2020-07-09 14:58:29 +02:00
committed by GitHub
parent ef8572f10d
commit a4427f3635
16 changed files with 97 additions and 43 deletions
+4 -2
View File
@@ -18,7 +18,7 @@
//! In-memory implementation of `Database`
use std::collections::HashMap;
use crate::{Database, Transaction, ColumnId, Change};
use crate::{Database, Change, ColumnId, Transaction, error};
use parking_lot::RwLock;
#[derive(Default)]
@@ -29,7 +29,7 @@ pub struct MemDb<H: Clone + Send + Sync + Eq + PartialEq + Default + std::hash::
impl<H> Database<H> for MemDb<H>
where H: Clone + Send + Sync + Eq + PartialEq + Default + std::hash::Hash
{
fn commit(&self, transaction: Transaction<H>) {
fn commit(&self, transaction: Transaction<H>) -> error::Result<()> {
let mut s = self.0.write();
for change in transaction.0.into_iter() {
match change {
@@ -39,6 +39,8 @@ impl<H> Database<H> for MemDb<H>
Change::Release(hash) => { s.1.remove(&hash); },
}
}
Ok(())
}
fn get(&self, col: ColumnId, key: &[u8]) -> Option<Vec<u8>> {