Added log to give insight about media insert failures.
This commit is contained in:
parent
38f53d8de8
commit
a04c7dda37
14
src/media.js
14
src/media.js
|
@ -688,11 +688,16 @@ async function storeMedias(baseMedias, options) {
|
||||||
const newMediaWithEntries = savedMedias.filter(Boolean).map((media, index) => curateMediaEntry(media, index));
|
const newMediaWithEntries = savedMedias.filter(Boolean).map((media, index) => curateMediaEntry(media, index));
|
||||||
const newMediaEntries = newMediaWithEntries.filter(media => media.newEntry).map(media => media.entry);
|
const newMediaEntries = newMediaWithEntries.filter(media => media.newEntry).map(media => media.entry);
|
||||||
|
|
||||||
// TODO: path duplicates disappear in DO NOTHING query, causing association error. source duplicate detection not working? use scene generator
|
try {
|
||||||
// await bulkInsert('media', newMediaEntries, false);
|
// TODO: path duplicates disappear in DO NOTHING query, causing association error. source duplicate detection not working? use scene generator
|
||||||
await bulkInsert('media', newMediaEntries);
|
// UPDATE: cannot replicate when using the same poster and photo source in scene generator
|
||||||
|
// await bulkInsert('media', newMediaEntries, false);
|
||||||
|
await bulkInsert('media', newMediaEntries);
|
||||||
|
|
||||||
return [...newMediaWithEntries, ...existingHashMedias];
|
return [...newMediaWithEntries, ...existingHashMedias];
|
||||||
|
} catch (error) {
|
||||||
|
throw Object.assign(error, { entries: newMediaEntries });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function associateReleaseMedia(releases, type = 'release') {
|
async function associateReleaseMedia(releases, type = 'release') {
|
||||||
|
@ -757,6 +762,7 @@ async function associateReleaseMedia(releases, type = 'release') {
|
||||||
await bulkInsert(`${type}s_${role}`, associations, false);
|
await bulkInsert(`${type}s_${role}`, associations, false);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
logger.error(util.inspect(error.entries, null, null, { color: true }));
|
||||||
logger.error(`Failed to store ${type} ${role}: ${error.message}`);
|
logger.error(`Failed to store ${type} ${role}: ${error.message}`);
|
||||||
}
|
}
|
||||||
}, Promise.resolve());
|
}, Promise.resolve());
|
||||||
|
|
|
@ -240,23 +240,15 @@ async function fetchLatest(entity, page, options) {
|
||||||
release.photos = Array.from({ length: Math.floor(Math.random() * 10) + 1 }, () => `${options.source}?id=${nanoid()}`); // ensure source is unique
|
release.photos = Array.from({ length: Math.floor(Math.random() * 10) + 1 }, () => `${options.source}?id=${nanoid()}`); // ensure source is unique
|
||||||
} else {
|
} else {
|
||||||
// select from local SFW database
|
// select from local SFW database
|
||||||
const [/* poster */, ...photos] = await knex('media')
|
const [poster, ...photos] = await knex('media')
|
||||||
.select('path')
|
.select('path')
|
||||||
.where('is_sfw', true)
|
.where('is_sfw', true)
|
||||||
.pluck('path')
|
.pluck('path')
|
||||||
.orderByRaw('random()')
|
.orderByRaw('random()')
|
||||||
.limit(Math.floor(Math.random() * 10) + 1);
|
.limit(Math.floor(Math.random() * 10) + 1);
|
||||||
|
|
||||||
const [poster] = await knex('media')
|
release.poster = `http://${config.web.host}:${config.web.port}/img/${poster}?id=${nanoid()}`; // ensure source is unique
|
||||||
.select('path')
|
release.photos = photos.map(photo => `http://${config.web.host}:${config.web.port}/img/${photo}?id=${nanoid()}`);
|
||||||
.where('is_sfw', true)
|
|
||||||
.pluck('path')
|
|
||||||
.limit(1);
|
|
||||||
|
|
||||||
// release.poster = `http://${config.web.host}:${config.web.port}/img/${poster}?id=${nanoid()}`; // ensure source is unique
|
|
||||||
release.poster = `http://${config.web.host}:${config.web.port}/img/${poster}`; // ensure source is unique
|
|
||||||
// release.photos = photos.map(photo => `http://${config.web.host}:${config.web.port}/img/${photo}?id=${nanoid()}`);
|
|
||||||
release.photos = [release.poster];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
release.tags = await knex('tags')
|
release.tags = await knex('tags')
|
||||||
|
|
Loading…
Reference in New Issue