diff --git a/src/database.rs b/src/database.rs
index 5999724..4994db3 100644
--- a/src/database.rs
+++ b/src/database.rs
@@ -67,6 +67,12 @@ impl Hashable for Entry {
}
}
+impl Entry {
+ pub fn address(&self) -> Result
{
+ Ok(Address::Hash(self.hash()?))
+ }
+}
+
impl EntryValue {
pub fn to_string(&self) -> Result {
let (type_char, content) = match self {
diff --git a/src/routes.rs b/src/routes.rs
index 7489d5b..da349a6 100644
--- a/src/routes.rs
+++ b/src/routes.rs
@@ -3,7 +3,7 @@ use crate::database::{
insert_entry, query, remove_object, retrieve_file, retrieve_object, DbPool, Entry, Query,
};
use crate::filesystem::{list_directory, UPath};
-use crate::hash::{decode, encode, Hashable};
+use crate::hash::{decode, encode};
use crate::jobs::JobContainer;
use actix_files::NamedFile;
use actix_web::error::{ErrorBadRequest, ErrorInternalServerError, ErrorNotFound};
@@ -64,7 +64,13 @@ pub async fn get_query(
let mut result: HashMap = HashMap::new();
for entry in entries {
result.insert(
- encode(entry.hash().map_err(ErrorInternalServerError)?),
+ encode(
+ entry
+ .address()
+ .map_err(ErrorInternalServerError)?
+ .encode()
+ .map_err(ErrorInternalServerError)?,
+ ),
entry,
);
}
@@ -81,7 +87,7 @@ pub async fn get_object(
let response: Result> = retrieve_object(
&connection,
Address::decode(&decode(address_str.into_inner()).map_err(ErrorBadRequest)?)
- .map_err(ErrorInternalServerError)?,
+ .map_err(ErrorBadRequest)?,
);
debug!("{:?}", response);
@@ -89,7 +95,13 @@ pub async fn get_object(
let mut result: HashMap = HashMap::new();
for entry in response.map_err(error::ErrorInternalServerError)? {
result.insert(
- encode(entry.hash().map_err(ErrorInternalServerError)?),
+ encode(
+ entry
+ .address()
+ .map_err(ErrorInternalServerError)?
+ .encode()
+ .map_err(ErrorInternalServerError)?,
+ ),
entry,
);
}