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
}
}