1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2024-12-28 22:51:59 +00:00

fix(server): handle invalid directory item (#12534)

This commit is contained in:
Jason Rasmussen 2024-09-09 23:54:24 -04:00 committed by GitHub
parent 2c639d7fe4
commit 3127636c42
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 1 deletions

View file

@ -520,6 +520,16 @@ describe(MetadataService.name, () => {
);
});
it('should handle an invalid Directory Item', async () => {
assetMock.getByIds.mockResolvedValue([assetStub.image]);
metadataMock.readTags.mockResolvedValue({
MotionPhoto: 1,
ContainerDirectory: [{ Foo: 100 }],
});
await expect(sut.handleMetadataExtraction({ id: assetStub.image.id })).resolves.toBe(JobStatus.SUCCESS);
});
it('should extract the correct video orientation', async () => {
assetMock.getByIds.mockResolvedValue([assetStub.video]);
mediaMock.probe.mockResolvedValue(probeStub.videoStreamVertical2160p);

View file

@ -428,7 +428,7 @@ export class MetadataService {
if (isMotionPhoto && directory) {
for (const entry of directory) {
if (entry.Item.Semantic == 'MotionPhoto') {
if (entry?.Item?.Semantic == 'MotionPhoto') {
length = entry.Item.Length ?? 0;
padding = entry.Item.Padding ?? 0;
break;