fix(server): handle NaN in metadata extraction (#4221)

Fallback to null in event of invalid number.
This commit is contained in:
David Johnson
2023-09-27 15:17:18 -04:00
committed by GitHub
parent 3a44e8f8d3
commit 85efbc6984
4 changed files with 46 additions and 11 deletions

View File

@@ -0,0 +1,16 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
export class RemoveInvalidCoordinates1695660378655 implements MigrationInterface {
name = 'RemoveInvalidCoordinates1695660378655';
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`UPDATE "exif" SET "latitude" = NULL WHERE "latitude" IN ('NaN', 'Infinity', '-Infinity')`);
await queryRunner.query(
`UPDATE "exif" SET "longitude" = NULL WHERE "longitude" IN ('NaN', 'Infinity', '-Infinity')`,
);
}
public async down(): Promise<void> {
// Empty, data cannot be restored
}
}

View File

@@ -74,7 +74,7 @@ export class MetadataRepository implements IMetadataRepository {
getExifTags(path: string): Promise<ImmichTags | null> {
return exiftool
.read<ImmichTags>(path, undefined, {
.read(path, undefined, {
...DefaultReadTaskOptions,
defaultVideosToUTC: true,
@@ -87,6 +87,6 @@ export class MetadataRepository implements IMetadataRepository {
.catch((error) => {
this.logger.warn(`Error reading exif data (${path}): ${error}`, error?.stack);
return null;
});
}) as Promise<ImmichTags | null>;
}
}