Filter media by source to stop exceptions #33

Closed
opened 2021-02-11 00:14:10 +00:00 by Ghost · 1 comment

The hash can be different if the destination alters the file but the url is the same.

media.js

async function findHashDuplicates(medias) {
	const hashes = medias.map(media => media.meta?.hash || media.entry?.hash).filter(Boolean);
	const srcs = medias.map(media => media.src).filter(Boolean);

	const existingHashMediaEntries = await knex('media').whereIn('hash', hashes);
	const existingHashMediaEntriesByHash = itemsByKey(existingHashMediaEntries, 'hash');

	const existingSourceMediaEntries = await knex('media').whereIn('source', srcs);
	const existingSourceMediaEntriesBySource = itemsByKey(existingSourceMediaEntries, 'source');

	const uniqueHashMedias = medias.filter(media => !media.entry && !existingSourceMediaEntriesBySource[media.src] && !existingHashMediaEntriesByHash[media.meta?.hash]);


The hash can be different if the destination alters the file but the url is the same. media.js ``` async function findHashDuplicates(medias) { const hashes = medias.map(media => media.meta?.hash || media.entry?.hash).filter(Boolean); const srcs = medias.map(media => media.src).filter(Boolean); const existingHashMediaEntries = await knex('media').whereIn('hash', hashes); const existingHashMediaEntriesByHash = itemsByKey(existingHashMediaEntries, 'hash'); const existingSourceMediaEntries = await knex('media').whereIn('source', srcs); const existingSourceMediaEntriesBySource = itemsByKey(existingSourceMediaEntries, 'source'); const uniqueHashMedias = medias.filter(media => !media.entry && !existingSourceMediaEntriesBySource[media.src] && !existingHashMediaEntriesByHash[media.meta?.hash]); ```
https://gitea.unknown.name/pendulum/traxxx/issues/14
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: DebaucheryLibrarian/traxxx#33
No description provided.