fix compile with no default features

feat/vaults
Tomáš Mládek 2022-01-07 00:52:09 +01:00
parent f489558b65
commit 368eb90d5b
No known key found for this signature in database
GPG Key ID: ED21612889E75EC5
3 changed files with 10 additions and 9 deletions

View File

@ -20,12 +20,10 @@ use crate::database::UpEndDatabase;
mod addressing;
mod database;
mod filesystem;
mod previews;
mod routes;
mod util;
#[cfg(feature = "previews")]
mod previews;
const VERSION: &str = env!("CARGO_PKG_VERSION");
fn main() -> Result<()> {

View File

@ -26,6 +26,7 @@ pub struct PreviewStore {
locks: Mutex<HashMap<Hash, Arc<Mutex<PathBuf>>>>,
}
#[cfg(feature = "previews")]
impl PreviewStore {
pub fn new<P: AsRef<Path>>(path: P, db: Arc<UpEndDatabase>) -> Self {
PreviewStore {

View File

@ -220,7 +220,9 @@ pub async fn delete_object(
#[get("/api/all/attributes")]
pub async fn get_all_attributes(state: web::Data<State>) -> Result<HttpResponse, Error> {
let connection = state.upend.connection().map_err(ErrorInternalServerError)?;
let result = connection.get_all_attributes().map_err(ErrorInternalServerError)?;
let result = connection
.get_all_attributes()
.map_err(ErrorInternalServerError)?;
Ok(HttpResponse::Ok().json(result))
}
@ -322,6 +324,7 @@ pub async fn get_thumbnail(
state: web::Data<State>,
hash: web::Path<String>,
) -> Result<NamedFile, Error> {
#[cfg(feature = "previews")]
if let Some(preview_store) = &state.preview_store {
let address =
Address::decode(&decode(hash.into_inner()).map_err(ErrorInternalServerError)?)
@ -337,13 +340,12 @@ pub async fn get_thumbnail(
file = file.set_content_type(mime);
}
}
Ok(file)
return Ok(file);
} else {
Err(ErrorBadRequest(
return Err(ErrorBadRequest(
"Address does not refer to a previewable object.",
))
));
}
} else {
Err(error::ErrorNotImplemented("Previews not enabled."))
}
Err(error::ErrorNotImplemented("Previews not enabled."))
}