mirror of
https://github.com/immich-app/immich.git
synced 2025-06-03 05:34:32 -04:00
fix(server): handle number lists in metadata extraction (#4273)
This commit is contained in:
parent
d7e970dcea
commit
3e73cfb71a
@ -122,4 +122,14 @@ describe(MetadataService.name, () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('handleMetadataExtraction', () => {
|
||||||
|
it('should handle lists of numbers', async () => {
|
||||||
|
assetMock.getByIds.mockResolvedValue([assetStub.image1]);
|
||||||
|
storageMock.stat.mockResolvedValue({ size: 123456 } as any);
|
||||||
|
metadataMock.getExifTags.mockResolvedValue({ ISO: [160] as any });
|
||||||
|
await sut.handleMetadataExtraction({ id: assetStub.image1.id });
|
||||||
|
expect(assetMock.upsertExif).toHaveBeenCalledWith(expect.objectContaining({ iso: 160 }));
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -32,6 +32,11 @@ type ExifEntityWithoutGeocodeAndTypeOrm = Omit<
|
|||||||
const exifDate = (dt: ExifDateTime | string | undefined) => (dt instanceof ExifDateTime ? dt?.toDate() : null);
|
const exifDate = (dt: ExifDateTime | string | undefined) => (dt instanceof ExifDateTime ? dt?.toDate() : null);
|
||||||
|
|
||||||
const validate = <T>(value: T): NonNullable<T> | null => {
|
const validate = <T>(value: T): NonNullable<T> | null => {
|
||||||
|
// handle lists of numbers
|
||||||
|
if (Array.isArray(value)) {
|
||||||
|
value = value[0];
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof value === 'string') {
|
if (typeof value === 'string') {
|
||||||
// string means a failure to parse a number, throw out result
|
// string means a failure to parse a number, throw out result
|
||||||
return null;
|
return null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user