fix entry addresses for /api/obj
parent
3a8aa21692
commit
e462801823
|
@ -67,6 +67,12 @@ impl Hashable for Entry {
|
|||
}
|
||||
}
|
||||
|
||||
impl Entry {
|
||||
pub fn address(&self) -> Result<Address> {
|
||||
Ok(Address::Hash(self.hash()?))
|
||||
}
|
||||
}
|
||||
|
||||
impl EntryValue {
|
||||
pub fn to_string(&self) -> Result<String> {
|
||||
let (type_char, content) = match self {
|
||||
|
|
|
@ -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<String, Entry> = 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<Vec<Entry>> = 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<String, Entry> = 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,
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue