fix: real AP id tests, exact poster key check, exists port, list_movies fake

This commit is contained in:
2026-10-26 01:33:29 +01:00
parent 4cb2972f63
commit 818ab893a1
13 changed files with 395 additions and 80 deletions

View File

@@ -14,8 +14,9 @@ pub async fn execute(deps: &EnrichMovieDeps, cmd: EnrichMovieCommand) -> Result<
}
let Some(movie) = deps.movie_query.get_movie_by_id(&cmd.movie_id).await? else {
tracing::warn!(movie_id = %cmd.movie_id.value(), "enrich_movie: movie not found, storing profile only");
deps.movie_profile.upsert(&cmd.profile).await?;
// The movie row is written with the event, so a missing row means it was
// deleted. Do not store the profile: it is the "enrichment done" marker.
tracing::warn!(movie_id = %cmd.movie_id.value(), "enrich_movie: movie not found, skipping");
return Ok(());
};

View File

@@ -110,15 +110,24 @@ impl EventHandler for PosterSyncHandler {
movie_id,
external_metadata_id,
} => {
// The poster is stored under the movie id and the movie row is
// updated atomically with `PosterSynced`; a poster already keyed
// by this movie means an earlier delivery completed.
// The poster is stored under the movie id (the converter later
// appends `.webp`/`.avif`) and the movie row is updated
// atomically with `PosterSynced`; exactly that path on the movie
// means an earlier delivery completed.
let id_str = movie_id.value().to_string();
let canonical = [
id_str.clone(),
format!("{id_str}.webp"),
format!("{id_str}.avif"),
];
let already_synced = self
.movie_query
.get_movie_by_id(&MovieId::from_uuid(movie_id.value()))
.await?
.and_then(|m| m.poster_path().map(|p| p.value().contains(&id_str)))
.and_then(|m| {
m.poster_path()
.map(|p| canonical.iter().any(|k| k == p.value()))
})
.unwrap_or(false);
if already_synced {
return Ok(());