Improved duplicate handling. Added tag photos.

This commit is contained in:
DebaucheryLibrarian
2021-02-21 22:17:25 +01:00
parent a39750d808
commit 8a739893ea
11 changed files with 11 additions and 6 deletions

View File

@@ -605,7 +605,12 @@ async function trySource(baseSource, existingMedias, baseMedia) {
};
}
return fetchSource(extractedSource, baseMedia);
const source = await fetchSource(extractedSource, baseMedia);
return {
...source,
entry: extractedSource.entry || existingSourceMedia,
};
}
async function fetchMedia(baseMedia, existingMedias) {
@@ -698,9 +703,6 @@ async function storeMedias(baseMedias, options) {
const newMediaEntries = newMediaWithEntries.filter(media => media.newEntry).map(media => media.entry);
try {
// TODO: path duplicates disappear in DO NOTHING query, causing association error. source duplicate detection not working? use scene generator
// 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];

View File

@@ -251,6 +251,8 @@ async function fetchLatest(entity, page, options) {
.orderByRaw('random()')
.limit(Math.floor(Math.random() * 10) + 1);
// const poster = 'sfw/kittens/thumbs/iNEXVlX-RLs.jpeg';
release.poster = `http://${config.web.host}:${config.web.port}/img/${poster}?id=${nanoid()}`; // ensure source is unique
release.photos = photos.map(photo => `http://${config.web.host}:${config.web.port}/img/${photo}?id=${nanoid()}`);
}