feat(database): remove unused SQL queries and update Cargo dependencies

This commit is contained in:
2026-05-04 14:00:33 +02:00
parent d769a5b55c
commit fa8efbaa23
22 changed files with 89 additions and 687 deletions

View File

@@ -9,6 +9,7 @@ anyhow = { workspace = true }
async-trait = { workspace = true }
tracing = { workspace = true }
object_store = { workspace = true }
infer = "0.19.0"
[dev-dependencies]
tokio = { workspace = true }

View File

@@ -7,9 +7,15 @@ use domain::{
ports::PosterStorage,
value_objects::{MovieId, PosterPath},
};
use object_store::{path::Path, ObjectStore};
use object_store::{Attribute, Attributes, PutOptions, path::Path, ObjectStore};
use std::sync::Arc;
fn detect_mime(bytes: &[u8]) -> &'static str {
infer::get(bytes)
.map(|t| t.mime_type())
.unwrap_or("application/octet-stream")
}
pub struct PosterStorageAdapter {
store: Arc<dyn ObjectStore>,
}
@@ -32,8 +38,12 @@ impl PosterStorage for PosterStorageAdapter {
image_bytes: &[u8],
) -> Result<PosterPath, DomainError> {
let path = Path::from(movie_id.value().to_string());
let mime = detect_mime(image_bytes);
let mut attributes = Attributes::new();
attributes.insert(Attribute::ContentType, mime.into());
let opts = PutOptions { attributes, ..Default::default() };
self.store
.put(&path, image_bytes.to_vec().into())
.put_opts(&path, image_bytes.to_vec().into(), opts)
.await
.map_err(|e| DomainError::InfrastructureError(e.to_string()))?;
PosterPath::new(path.to_string())

View File

@@ -5,7 +5,7 @@
<article class="entry">
{% if let Some(poster) = entry.movie().poster_path() %}
<div class="poster">
<img src="/static/posters/{{ poster.value() }}" alt="">
<img src="/posters/{{ poster.value() }}" alt="">
</div>
{% endif %}
<div class="entry-body">