mirror of
https://github.com/immich-app/immich.git
synced 2024-12-28 06:31:58 +00:00
fix(server): exif description whitespace handling (#11249)
* fix(server): exif description whitespace handling * remove trim optional chaining
This commit is contained in:
parent
1e8806854d
commit
8b773a2b2e
2 changed files with 23 additions and 1 deletions
|
@ -710,6 +710,26 @@ describe(MetadataService.name, () => {
|
|||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('trims whitespace from description', async () => {
|
||||
assetMock.getByIds.mockResolvedValue([assetStub.image]);
|
||||
metadataMock.readTags.mockResolvedValue({ Description: '\t \v \f \n \r' });
|
||||
|
||||
await sut.handleMetadataExtraction({ id: assetStub.image.id });
|
||||
expect(assetMock.upsertExif).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
description: '',
|
||||
}),
|
||||
);
|
||||
|
||||
metadataMock.readTags.mockResolvedValue({ ImageDescription: ' my\n description' });
|
||||
await sut.handleMetadataExtraction({ id: assetStub.image.id });
|
||||
expect(assetMock.upsertExif).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
description: 'my\n description',
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('handleQueueSidecar', () => {
|
||||
|
@ -889,6 +909,7 @@ describe(MetadataService.name, () => {
|
|||
}),
|
||||
).resolves.toBe(JobStatus.SUCCESS);
|
||||
expect(metadataMock.writeTags).toHaveBeenCalledWith(assetStub.sidecar.sidecarPath, {
|
||||
Description: description,
|
||||
ImageDescription: description,
|
||||
CreationDate: date,
|
||||
GPSLatitude: gps,
|
||||
|
|
|
@ -314,6 +314,7 @@ export class MetadataService implements OnEvents {
|
|||
const sidecarPath = asset.sidecarPath || `${asset.originalPath}.xmp`;
|
||||
const exif = _.omitBy<Tags>(
|
||||
{
|
||||
Description: description,
|
||||
ImageDescription: description,
|
||||
CreationDate: dateTimeOriginal,
|
||||
GPSLatitude: latitude,
|
||||
|
@ -512,7 +513,7 @@ export class MetadataService implements OnEvents {
|
|||
bitsPerSample: this.getBitsPerSample(tags),
|
||||
colorspace: tags.ColorSpace ?? null,
|
||||
dateTimeOriginal: this.getDateTimeOriginal(tags) ?? asset.fileCreatedAt,
|
||||
description: (tags.ImageDescription || tags.Description) ?? '',
|
||||
description: (tags.ImageDescription || tags.Description || '').trim(),
|
||||
exifImageHeight: validate(tags.ImageHeight),
|
||||
exifImageWidth: validate(tags.ImageWidth),
|
||||
exposureTime: tags.ExposureTime ?? null,
|
||||
|
|
Loading…
Reference in a new issue