Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/system/database.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::collections::HashMap;
use std::io;
use std::io::ErrorKind;

use crate::{ChunkHash, MB};

Expand Down Expand Up @@ -78,7 +77,7 @@ impl<Hash: ChunkHash, V: Clone> Database<Hash, V> for HashMap<Hash, V> {
}

fn get(&self, key: &Hash) -> io::Result<V> {
self.get(key).ok_or(ErrorKind::NotFound.into()).cloned()
self.get(key).ok_or(io::ErrorKind::NotFound.into()).cloned()
}

fn contains(&self, key: &Hash) -> bool {
Expand Down Expand Up @@ -152,7 +151,7 @@ where
fn insert(&mut self, key: K, value: V, value_size: usize) -> io::Result<()> {
if self.size + value_size > self.max_size {
let msg = "The container is too full for the desired data";
return Err(io::Error::new(io::ErrorKind::OutOfMemory, msg));
return Err(io::Error::new(io::ErrorKind::InvalidInput, msg));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Как будто не лучший вид ошибки, все таки ввод то у нас полностьстью валидный, ошибка у нас из за заполнености БД, тут скорее подойдет std::io::other может

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Согласно таске необходимо было заменить OutOfMemory на InvalidInput, сделано согласно ТЗ

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Оки, я баклан, не прочитал твое ТЗ =) Извини

}

self.values.insert(key, value);
Expand All @@ -165,7 +164,7 @@ where
fn get(&self, key: &K) -> io::Result<V> {
self.values
.get(key)
.ok_or(ErrorKind::NotFound.into())
.ok_or(io::ErrorKind::NotFound.into())
.cloned()
}
}
Expand Down