retireve_file takes reference
parent
2337cd54c1
commit
8d51529f38
|
@ -222,12 +222,12 @@ impl UpEndConnection {
|
|||
.unwrap())
|
||||
}
|
||||
|
||||
pub fn retrieve_file(&self, obj_hash: Hash) -> Result<Vec<models::OutFile>> {
|
||||
pub fn retrieve_file(&self, obj_hash: &Hash) -> Result<Vec<models::OutFile>> {
|
||||
use crate::database::inner::schema::files::dsl::*;
|
||||
|
||||
let matches = files
|
||||
.filter(valid.eq(true))
|
||||
.filter(hash.eq(obj_hash.0))
|
||||
.filter(hash.eq(&obj_hash.0))
|
||||
.load::<models::File>(&self.conn)?;
|
||||
|
||||
let matches = matches
|
||||
|
|
|
@ -58,7 +58,7 @@ impl PreviewStore {
|
|||
Ok(Some(thumbpath.clone()))
|
||||
} else {
|
||||
let connection = self.db.connection()?;
|
||||
let files = connection.retrieve_file(hash)?;
|
||||
let files = connection.retrieve_file(&hash)?;
|
||||
if let Some(file) = files.get(0) {
|
||||
let preview = match tree_magic_mini::from_filepath(&file.path) {
|
||||
Some(tm) if tm.starts_with("text") => Ok(TextPath(&file.path).get_thumbnail()?),
|
||||
|
|
|
@ -66,7 +66,7 @@ pub async fn get_raw(
|
|||
|
||||
// Then, check the files
|
||||
let files = connection
|
||||
.retrieve_file(hash)
|
||||
.retrieve_file(&hash)
|
||||
.map_err(ErrorInternalServerError)?;
|
||||
if let Some(file) = files.get(0) {
|
||||
let file_path = state.upend.vault_path.join(&file.path);
|
||||
|
@ -268,7 +268,7 @@ pub async fn put_object(
|
|||
let connection = state.upend.connection().map_err(ErrorInternalServerError)?;
|
||||
|
||||
let existing_files = connection
|
||||
.retrieve_file(hash.clone())
|
||||
.retrieve_file(&hash)
|
||||
.map_err(ErrorInternalServerError)?;
|
||||
|
||||
if existing_files.is_empty() {
|
||||
|
@ -465,7 +465,7 @@ pub async fn get_file(
|
|||
if let Address::Hash(hash) = address {
|
||||
let connection = state.upend.connection().map_err(ErrorInternalServerError)?;
|
||||
let response = connection
|
||||
.retrieve_file(hash)
|
||||
.retrieve_file(&hash)
|
||||
.map_err(ErrorInternalServerError)?;
|
||||
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
|
|
Loading…
Reference in New Issue