1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00

fixing photo metadata data type error with mysql

This commit is contained in:
Patrik J. Braun 2019-02-02 18:18:35 -05:00
parent 7c46f61a2d
commit 459cc8c867
5 changed files with 49 additions and 18 deletions

View File

@ -45,7 +45,7 @@ export class SQLConnection {
VersionEntity
];
options.synchronize = false;
// options.logging = 'all';
options.logging = 'all';
this.connection = await this.createConnection(options);

View File

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

View File

@ -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++) {

View File

@ -1 +1 @@
export const DataStructureVersion = 9;
export const DataStructureVersion = 10;

View File

@ -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();