forked from DebaucheryLibrarian/traxxx
Catching media storage errors to prevent full crash.
This commit is contained in:
parent
c9b774c498
commit
688863d16e
42
src/media.js
42
src/media.js
|
@ -731,29 +731,33 @@ async function associateReleaseMedia(releases, type = 'release') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const storedMedias = await storeMedias(baseMedias);
|
try {
|
||||||
const storedMediasById = itemsByKey(storedMedias, 'id');
|
const storedMedias = await storeMedias(baseMedias);
|
||||||
|
const storedMediasById = itemsByKey(storedMedias, 'id');
|
||||||
|
|
||||||
const associations = Object
|
const associations = Object
|
||||||
.entries(baseMediasByReleaseId)
|
.entries(baseMediasByReleaseId)
|
||||||
.reduce((acc, [releaseId, releaseBaseMedias]) => {
|
.reduce((acc, [releaseId, releaseBaseMedias]) => {
|
||||||
releaseBaseMedias.forEach((baseMedia) => {
|
releaseBaseMedias.forEach((baseMedia) => {
|
||||||
const media = storedMediasById[baseMedia.id];
|
const media = storedMediasById[baseMedia.id];
|
||||||
|
|
||||||
if (media) {
|
if (media) {
|
||||||
acc.push({
|
acc.push({
|
||||||
[`${type}_id`]: releaseId,
|
[`${type}_id`]: releaseId,
|
||||||
media_id: media.use || media.entry.id,
|
media_id: media.use || media.entry.id,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return acc;
|
return acc;
|
||||||
}, [])
|
}, [])
|
||||||
.filter(Boolean);
|
.filter(Boolean);
|
||||||
|
|
||||||
if (associations.length > 0) {
|
if (associations.length > 0) {
|
||||||
await bulkInsert(`${type}s_${role}`, associations, false);
|
await bulkInsert(`${type}s_${role}`, associations, false);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(`Failed to store ${type} ${role}: ${error.message}`);
|
||||||
}
|
}
|
||||||
}, Promise.resolve());
|
}, Promise.resolve());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue