Transferring release media types separately to prevent race conditions.

This commit is contained in:
DebaucheryLibrarian 2023-06-04 04:17:01 +02:00
parent 042d3be4a9
commit caf37ba9fb
1 changed files with 11 additions and 9 deletions

View File

@ -564,20 +564,22 @@ async function addRelease(release, context) {
entityName: entity.name, entityName: entity.name,
}; };
await addReleaseMedia([releaseWithId.poster], releaseWithId, 'posters', context);
if (release.type === 'release') {
await Promise.all([ await Promise.all([
addReleaseMedia([releaseWithId.poster], releaseWithId, 'posters', context),
...(release.type === 'release' ? [
addReleaseTags(releaseWithId, context), addReleaseTags(releaseWithId, context),
addReleaseActors(releaseWithId, context), addReleaseActors(releaseWithId, context),
addReleaseDirectors(releaseWithId, context), addReleaseDirectors(releaseWithId, context),
addReleaseChapters(releaseWithId, context), addReleaseChapters(releaseWithId, context),
addReleaseMedia(releaseWithId.photos, releaseWithId, 'photos', context),
linkMovieScenes(releaseWithId, context), linkMovieScenes(releaseWithId, context),
] : []), addReleaseMedia(releaseWithId.photos, releaseWithId, 'photos', context),
...(release.type === 'movie' ? [
addReleaseMedia(releaseWithId.covers, releaseWithId, 'covers', context),
] : []),
]); ]);
}
if (release.type === 'movie') {
await addReleaseMedia(releaseWithId.covers, releaseWithId, 'covers', context);
}
return releaseWithId; return releaseWithId;
} }