diff --git a/backend/model/threading/DiskMangerWorker.ts b/backend/model/threading/DiskMangerWorker.ts index 0d80b181..a6627f13 100644 --- a/backend/model/threading/DiskMangerWorker.ts +++ b/backend/model/threading/DiskMangerWorker.ts @@ -43,15 +43,17 @@ export class DiskMangerWorker { try { - fs.stat(fullPath, (err, data) => { - metadata.fileSize = data.size; - }); + try { + const stat = fs.statSync(fullPath); + metadata.fileSize = stat.size; + } catch (err) { + } try { const exif = exif_parser.create(data).parse(); metadata.cameraData = { ISO: exif.tags.ISO, - model: exif.tags.Model, + model: exif.tags.Model.toString("utf8"), make: exif.tags.Make, fStop: exif.tags.FNumber, exposure: exif.tags.ExposureTime, @@ -100,7 +102,6 @@ export class DiskMangerWorker { Logger.info(LOG_TAG, "Error parsing iptc data", fullPath); } - return resolve(metadata); } catch (err) { return reject({file: fullPath, error: err}); diff --git a/frontend/app/gallery/lightbox/lightbox.gallery.component.ts b/frontend/app/gallery/lightbox/lightbox.gallery.component.ts index 25f2a7e8..fd7c0324 100644 --- a/frontend/app/gallery/lightbox/lightbox.gallery.component.ts +++ b/frontend/app/gallery/lightbox/lightbox.gallery.component.ts @@ -97,7 +97,6 @@ export class GalleryLightboxComponent implements OnDestroy { activePhotoId: number = null; private showPhoto(photoIndex: number, resize: boolean = true) { - console.log("showing photo"); this.activePhoto = null; this.changeDetector.detectChanges(); this.updateActivePhoto(photoIndex, resize); diff --git a/package.json b/package.json index 6e5aef36..b83ce597 100644 --- a/package.json +++ b/package.json @@ -55,6 +55,7 @@ "@angular/platform-browser-dynamic": "~4.3.0", "@angular/router": "~4.3.0", "@types/bcryptjs": "^2.4.0", + "@types/chai": "^4.0.1", "@types/express": "^4.0.36", "@types/express-session": "1.15.1", "@types/gm": "^1.17.31", diff --git a/test/backend/unit/assets/test image öüóőúéáű-.,.jpg b/test/backend/unit/assets/test image öüóőúéáű-.,.jpg new file mode 100644 index 00000000..b44dcb5d Binary files /dev/null and b/test/backend/unit/assets/test image öüóőúéáű-.,.jpg differ diff --git a/test/backend/unit/middlewares/uesr/AuthenticationMWs.ts b/test/backend/unit/middlewares/user/AuthenticationMWs.ts similarity index 100% rename from test/backend/unit/middlewares/uesr/AuthenticationMWs.ts rename to test/backend/unit/middlewares/user/AuthenticationMWs.ts diff --git a/test/backend/unit/model/threading/DiskMangerWorker.spec.ts b/test/backend/unit/model/threading/DiskMangerWorker.spec.ts new file mode 100644 index 00000000..c0d7ceae --- /dev/null +++ b/test/backend/unit/model/threading/DiskMangerWorker.spec.ts @@ -0,0 +1,44 @@ +import {expect} from "chai"; +import {DiskMangerWorker} from "../../../../../backend/model/threading/DiskMangerWorker"; +import * as path from "path"; +import {Config} from "../../../../../common/config/private/Config"; +import {ProjectPath} from "../../../../../backend/ProjectPath"; + +describe('DiskMangerWorker', () => { + + it('should call next on authenticated', async () => { + Config.Server.imagesFolder = path.join(__dirname, "/../../assets"); + ProjectPath.ImageFolder = path.join(__dirname, "/../../assets"); + const dir = await DiskMangerWorker.scanDirectory("/"); + console.log(dir.photos[0].metadata); + expect(dir.photos.length).to.be.equals(1); + expect(dir.photos[0].name).to.be.equals("test image öüóőúéáű-.,.jpg"); + expect(dir.photos[0].metadata.keywords).to.deep.equals(['Berkley,USA']); + expect(dir.photos[0].metadata.fileSize).to.deep.equals(57172); + expect(dir.photos[0].metadata.size).to.deep.equals({width: 140, height: 93}); + expect(dir.photos[0].metadata.cameraData).to.deep.equals({ + ISO: 3200, + model: 'óüöúőűáé ÓÜÖÚŐŰÁÉ', + make: 'Canon', + fStop: 5.6, + exposure: 0.00125, + focalLength: 85, + lens: 'EF-S15-85mm f/3.5-5.6 IS USM' + }); + + expect(dir.photos[0].metadata.positionData).to.deep.equals({ + GPSData: { + latitude: 37.871093333333334, + longitude: -122.25678, + altitude: 102.4498997995992 + }, + country: 'óüöúőűáé ÓÜÖÚŐŰÁÉ', + state: 'óüöúőűáé ÓÜÖÚŐŰÁÉ', + city: 'óüöúőűáé ÓÜÖÚŐŰÁÉ' + }); + + expect(dir.photos[0].metadata.creationDate).to.be.equals(1436610566000); + + }); + +});