Storing avatars in actors avatars table to allow multiple (historical) photos per profile.
This commit is contained in:
13
src/media.js
13
src/media.js
@@ -838,7 +838,10 @@ function curateMediaEntry(media, index) {
|
||||
async function storeMedias(baseMedias, options) {
|
||||
await fsPromises.mkdir(path.join(config.media.path, 'temp'), { recursive: true });
|
||||
|
||||
const { existingSourceMediaByUrl, existingExtractMediaByUrl } = await findSourceDuplicates(baseMedias);
|
||||
// avatars often have different images at the same URL, skip URL dedupe until more advanced source deduping is implemented
|
||||
const { existingSourceMediaByUrl, existingExtractMediaByUrl } = options.type === 'avatars'
|
||||
? { existingSourceMediaByUrl: {}, existingExtractMediaByUrl: {} }
|
||||
: await findSourceDuplicates(baseMedias);
|
||||
|
||||
const fetchedMedias = await Promise.map(
|
||||
baseMedias,
|
||||
@@ -914,7 +917,7 @@ async function associateReleaseMedia(releases, type = 'release') {
|
||||
}
|
||||
|
||||
try {
|
||||
const storedMedias = await storeMedias(baseMedias);
|
||||
const storedMedias = await storeMedias(baseMedias, { type });
|
||||
const storedMediasById = itemsByKey(storedMedias, 'id');
|
||||
|
||||
const associations = Object
|
||||
@@ -967,10 +970,10 @@ async function associateAvatars(profiles) {
|
||||
|
||||
const baseMedias = profilesWithBaseMedias.map((profile) => profile.avatarBaseMedia).filter(Boolean);
|
||||
|
||||
const storedMedias = await storeMedias(baseMedias, { stats: true });
|
||||
const storedMedias = await storeMedias(baseMedias, { type: 'avatars', stats: true });
|
||||
const storedMediasById = itemsByKey(storedMedias, 'id');
|
||||
|
||||
const profilesWithAvatarIds = profilesWithBaseMedias.map((profile) => {
|
||||
const profilesWithAvatarId = profilesWithBaseMedias.map((profile) => {
|
||||
const media = storedMediasById[profile.avatarBaseMedia?.id];
|
||||
|
||||
if (media) {
|
||||
@@ -983,7 +986,7 @@ async function associateAvatars(profiles) {
|
||||
return profile;
|
||||
});
|
||||
|
||||
return profilesWithAvatarIds;
|
||||
return profilesWithAvatarId;
|
||||
}
|
||||
|
||||
async function deleteS3Objects(media) {
|
||||
|
||||
Reference in New Issue
Block a user