mirror of
https://github.com/immich-app/immich.git
synced 2026-02-28 09:38:43 +03:00
fix: metadata crash (#26327)
This commit is contained in:
@@ -36,6 +36,7 @@ import { mergeTimeZone } from 'src/utils/date';
|
|||||||
import { mimeTypes } from 'src/utils/mime-types';
|
import { mimeTypes } from 'src/utils/mime-types';
|
||||||
import { isFaceImportEnabled } from 'src/utils/misc';
|
import { isFaceImportEnabled } from 'src/utils/misc';
|
||||||
import { upsertTags } from 'src/utils/tag';
|
import { upsertTags } from 'src/utils/tag';
|
||||||
|
import { Tasks } from 'src/utils/tasks';
|
||||||
|
|
||||||
/** look for a date from these tags (in order) */
|
/** look for a date from these tags (in order) */
|
||||||
const EXIF_DATE_TAGS: Array<keyof ImmichTags> = [
|
const EXIF_DATE_TAGS: Array<keyof ImmichTags> = [
|
||||||
@@ -307,7 +308,10 @@ export class MetadataService extends BaseService {
|
|||||||
const assetWidth = isSidewards ? validate(height) : validate(width);
|
const assetWidth = isSidewards ? validate(height) : validate(width);
|
||||||
const assetHeight = isSidewards ? validate(width) : validate(height);
|
const assetHeight = isSidewards ? validate(width) : validate(height);
|
||||||
|
|
||||||
const promises: Promise<unknown>[] = [
|
const tasks = new Tasks();
|
||||||
|
|
||||||
|
tasks.push(
|
||||||
|
() =>
|
||||||
this.assetRepository.update({
|
this.assetRepository.update({
|
||||||
id: asset.id,
|
id: asset.id,
|
||||||
duration: this.getDuration(exifTags),
|
duration: this.getDuration(exifTags),
|
||||||
@@ -320,20 +324,22 @@ export class MetadataService extends BaseService {
|
|||||||
width: asset.width == null ? assetWidth : undefined,
|
width: asset.width == null ? assetWidth : undefined,
|
||||||
height: asset.height == null ? assetHeight : undefined,
|
height: asset.height == null ? assetHeight : undefined,
|
||||||
}),
|
}),
|
||||||
];
|
async () => {
|
||||||
|
|
||||||
await this.assetRepository.upsertExif(exifData, { lockedPropertiesBehavior: 'skip' });
|
await this.assetRepository.upsertExif(exifData, { lockedPropertiesBehavior: 'skip' });
|
||||||
await this.applyTagList(asset);
|
await this.applyTagList(asset);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
if (this.isMotionPhoto(asset, exifTags)) {
|
if (this.isMotionPhoto(asset, exifTags)) {
|
||||||
promises.push(this.applyMotionPhotos(asset, exifTags, dates, stats));
|
tasks.push(() => this.applyMotionPhotos(asset, exifTags, dates, stats));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isFaceImportEnabled(metadata) && this.hasTaggedFaces(exifTags)) {
|
if (isFaceImportEnabled(metadata) && this.hasTaggedFaces(exifTags)) {
|
||||||
promises.push(this.applyTaggedFaces(asset, exifTags));
|
tasks.push(() => this.applyTaggedFaces(asset, exifTags));
|
||||||
}
|
}
|
||||||
|
|
||||||
await Promise.all(promises);
|
await tasks.all();
|
||||||
|
|
||||||
if (exifData.livePhotoCID) {
|
if (exifData.livePhotoCID) {
|
||||||
await this.linkLivePhotos(asset, exifData);
|
await this.linkLivePhotos(asset, exifData);
|
||||||
}
|
}
|
||||||
|
|||||||
13
server/src/utils/tasks.ts
Normal file
13
server/src/utils/tasks.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
export type Task = () => Promise<unknown> | unknown;
|
||||||
|
|
||||||
|
export class Tasks {
|
||||||
|
private tasks: Task[] = [];
|
||||||
|
|
||||||
|
push(...tasks: Task[]) {
|
||||||
|
this.tasks.push(...tasks);
|
||||||
|
}
|
||||||
|
|
||||||
|
async all() {
|
||||||
|
await Promise.all(this.tasks.map((item) => item()));
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user