Preventing media associations when use-reference is unavailable.
This commit is contained in:
12
src/media.js
12
src/media.js
@@ -828,7 +828,7 @@ async function associateReleaseMedia(releases, type = 'release') {
|
||||
const media = storedMediasById[baseMedia.id];
|
||||
const mediaId = media?.use || media?.entry?.id;
|
||||
|
||||
if (mediaId) {
|
||||
if (mediaId && storedMediasById[mediaId]) {
|
||||
acc.push({
|
||||
[`${type}_id`]: releaseId,
|
||||
media_id: mediaId,
|
||||
@@ -840,14 +840,8 @@ async function associateReleaseMedia(releases, type = 'release') {
|
||||
}, [])
|
||||
.filter(Boolean);
|
||||
|
||||
try {
|
||||
if (associations.length > 0) {
|
||||
await bulkInsert(`${type}s_${role}`, associations, false);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(associations);
|
||||
await fs.promises.writeFile(`./associations-${Date.now()}`, JSON.stringify(associations, null, 4));
|
||||
throw error;
|
||||
if (associations.length > 0) {
|
||||
await bulkInsert(`${type}s_${role}`, associations, false);
|
||||
}
|
||||
} catch (error) {
|
||||
if (error.entries) {
|
||||
|
||||
Reference in New Issue
Block a user