fix: release db connection

This commit is contained in:
kieran 2025-01-25 23:52:42 +00:00
parent 0bd531a21d
commit 71f6f47a00
No known key found for this signature in database
GPG Key ID: DE71CEB3925BE941

View File

@ -389,7 +389,12 @@ pub async fn get_blob_thumb(
if id.len() != 32 {
return Err(Status::NotFound);
}
if let Ok(Some(info)) = db.get_file(&id).await {
let info = if let Ok(Some(info)) = db.get_file(&id).await {
info
} else {
return Err(Status::NotFound);
};
let file_path = fs.get(&id);
let mut thumb_file = temp_dir().join(format!("thumb_{}", sha256));
@ -403,18 +408,18 @@ pub async fn get_blob_thumb(
};
if let Ok(f) = File::open(&thumb_file).await {
return Ok(FilePayload {
Ok(FilePayload {
file: f,
info: FileUpload {
size: thumb_file.metadata().unwrap().len(),
mime_type: "image/webp".to_string(),
..info
},
});
}
}
})
} else {
Err(Status::NotFound)
}
}
/// Legacy URL redirect for void.cat uploads
#[rocket::get("/d/<id>")]