diff --git a/backend/model/sql/SQLConnection.ts b/backend/model/sql/SQLConnection.ts index 4ae051a6..02cf9bd8 100644 --- a/backend/model/sql/SQLConnection.ts +++ b/backend/model/sql/SQLConnection.ts @@ -45,7 +45,7 @@ export class SQLConnection { VersionEntity ]; options.synchronize = false; - // options.logging = 'all'; + options.logging = 'all'; this.connection = await this.createConnection(options); diff --git a/backend/model/sql/enitites/PhotoEntity.ts b/backend/model/sql/enitites/PhotoEntity.ts index 4fe49156..6ebaa568 100644 --- a/backend/model/sql/enitites/PhotoEntity.ts +++ b/backend/model/sql/enitites/PhotoEntity.ts @@ -1,13 +1,5 @@ -import {Column, Entity, ChildEntity, Unique} from 'typeorm'; -import { - CameraMetadata, - FaceRegion, - FaceRegionBox, - GPSMetadata, - PhotoDTO, - PhotoMetadata, - PositionMetaData -} from '../../../../common/entities/PhotoDTO'; +import {ChildEntity, Column} from 'typeorm'; +import {CameraMetadata, GPSMetadata, PhotoDTO, PhotoMetadata, PositionMetaData} from '../../../../common/entities/PhotoDTO'; import {MediaEntity, MediaMetadataEntity} from './MediaEntity'; export class CameraMetadataEntity implements CameraMetadata { @@ -21,13 +13,13 @@ export class CameraMetadataEntity implements CameraMetadata { @Column('text', {nullable: true}) make: string; - @Column('int', {nullable: true}) + @Column('float', {nullable: true}) fStop: number; - @Column('int', {nullable: true}) + @Column('float', {nullable: true}) exposure: number; - @Column('int', {nullable: true}) + @Column('int', {nullable: true, unsigned: true}) focalLength: number; @Column('text', {nullable: true}) @@ -37,11 +29,11 @@ export class CameraMetadataEntity implements CameraMetadata { export class GPSMetadataEntity implements GPSMetadata { - @Column('int', {nullable: true}) + @Column('float', {nullable: true}) latitude: number; - @Column('int', {nullable: true}) + @Column('float', {nullable: true}) longitude: number; - @Column('int', {nullable: true}) + @Column('float', {nullable: true}) altitude: number; } diff --git a/backend/model/threading/MetadataLoader.ts b/backend/model/threading/MetadataLoader.ts index 14a5eb9e..d2ca4572 100644 --- a/backend/model/threading/MetadataLoader.ts +++ b/backend/model/threading/MetadataLoader.ts @@ -174,7 +174,9 @@ export class MetadataLoader { try { + const ret = ExifReader.load(data); + ret.ImageWidth.id const faces: FaceRegion[] = []; if (ret.Regions && ret.Regions.value.RegionList && ret.Regions.value.RegionList.value) { for (let i = 0; i < ret.Regions.value.RegionList.value.length; i++) { diff --git a/common/DataStructureVersion.ts b/common/DataStructureVersion.ts index 950d63ab..8272ebda 100644 --- a/common/DataStructureVersion.ts +++ b/common/DataStructureVersion.ts @@ -1 +1 @@ -export const DataStructureVersion = 9; +export const DataStructureVersion = 10; diff --git a/test/backend/unit/model/sql/IndexingManager.ts b/test/backend/unit/model/sql/IndexingManager.ts index 1467e853..16a62db5 100644 --- a/test/backend/unit/model/sql/IndexingManager.ts +++ b/test/backend/unit/model/sql/IndexingManager.ts @@ -109,6 +109,43 @@ describe('IndexingManager', (sqlHelper: SQLTestHelper) => { .to.deep.equal(Utils.clone(Utils.removeNullOrEmptyObj(parent))); }); + + it('should save photos with extreme parameters', async () => { + const gm = new GalleryManagerTest(); + const im = new IndexingManagerTest(); + + const parent = TestHelper.getRandomizedDirectoryEntry(); + const p1 = TestHelper.getRandomizedPhotoEntry(parent, 'Photo1'); + const p2 = TestHelper.getRandomizedPhotoEntry(parent, 'Photo2'); + const minFloat = 1.1 * Math.pow(10, -38); + const maxFloat = 3.4 * Math.pow(10, +38); + p1.metadata.cameraData.fStop = minFloat; + p2.metadata.cameraData.fStop = maxFloat; + p1.metadata.cameraData.exposure = minFloat; + p2.metadata.cameraData.exposure = maxFloat; + p1.metadata.cameraData.focalLength = 0; + p2.metadata.cameraData.focalLength = 4294967295; + p1.metadata.positionData.GPSData.altitude = maxFloat; + p2.metadata.positionData.GPSData.altitude = minFloat; + p1.metadata.positionData.GPSData.latitude = maxFloat; + p2.metadata.positionData.GPSData.latitude = minFloat; + p1.metadata.positionData.GPSData.longitude = maxFloat; + p2.metadata.positionData.GPSData.longitude = minFloat; + + + DirectoryDTO.removeReferences(parent); + await im.saveToDB(Utils.clone(parent)); + + const conn = await SQLConnection.getConnection(); + const selected = await gm.selectParentDir(conn, parent.name, parent.path); + await gm.fillParentDir(conn, selected); + + DirectoryDTO.removeReferences(selected); + removeIds(selected); + expect(Utils.clone(Utils.removeNullOrEmptyObj(selected))) + .to.deep.equal(Utils.clone(Utils.removeNullOrEmptyObj(parent))); + }); + it('should skip meta files', async () => { const gm = new GalleryManagerTest(); const im = new IndexingManagerTest();