diff --git a/src/backend/middlewares/thumbnail/ThumbnailGeneratorMWs.ts b/src/backend/middlewares/thumbnail/ThumbnailGeneratorMWs.ts index b5fbb718..f403ea5f 100644 --- a/src/backend/middlewares/thumbnail/ThumbnailGeneratorMWs.ts +++ b/src/backend/middlewares/thumbnail/ThumbnailGeneratorMWs.ts @@ -42,7 +42,7 @@ export class ThumbnailGeneratorMWs { // tslint:disable-next-line:typedef - public static addThumbnailInfoForPersons(req: Request, res: Response, next: NextFunction): any { + public static addThumbnailInfoForPersons(req: Request, res: Response, next: NextFunction): void { if (!req.resultPipe) { return next(); } @@ -51,7 +51,11 @@ export class ThumbnailGeneratorMWs { const size: number = Config.Client.Media.Thumbnail.personThumbnailSize; const persons: PersonWithSampleRegion[] = req.resultPipe; + for (const item of persons) { + if (!item.sampleRegion) { + continue; + } // load parameters const mediaPath = path.join(ProjectPath.ImageFolder, item.sampleRegion.media.directory.path, diff --git a/src/backend/model/database/sql/GalleryManager.ts b/src/backend/model/database/sql/GalleryManager.ts index 9f250262..71d1bc21 100644 --- a/src/backend/model/database/sql/GalleryManager.ts +++ b/src/backend/model/database/sql/GalleryManager.ts @@ -77,10 +77,8 @@ export class GalleryManager implements IGalleryManager, ISQLGalleryManager { // on the fly reindexing Logger.silly(LOG_TAG, 'lazy reindexing reason: cache timeout: lastScanned: ' - + (Date.now() - dir.lastScanned) + ' ms ago, cachedFolderTimeout:' + Config.Server.Indexing.cachedFolderTimeout); - ObjectManagers.getInstance().IndexingManager.indexDirectory(relativeDirectoryName).catch((err): void => { - console.error(err); - }); + + (Date.now() - dir.lastScanned) + 'ms ago, cachedFolderTimeout:' + Config.Server.Indexing.cachedFolderTimeout); + ObjectManagers.getInstance().IndexingManager.indexDirectory(relativeDirectoryName).catch(console.error); } await this.fillParentDir(connection, dir); return dir; diff --git a/src/backend/model/database/sql/PersonManager.ts b/src/backend/model/database/sql/PersonManager.ts index c5e98c8e..90a22845 100644 --- a/src/backend/model/database/sql/PersonManager.ts +++ b/src/backend/model/database/sql/PersonManager.ts @@ -30,17 +30,6 @@ export class PersonManager implements ISQLPersonManager { return person; } - - private async loadAll(): Promise { - const connection = await SQLConnection.getConnection(); - const personRepository = connection.getRepository(PersonEntry); - this.persons = await personRepository.find({ - relations: ['sampleRegion', - 'sampleRegion.media', - 'sampleRegion.media.directory'] - }); - } - public async getAll(): Promise { if (this.persons === null) { await this.loadAll(); @@ -48,7 +37,6 @@ export class PersonManager implements ISQLPersonManager { return this.persons; } - /** * Used for statistic */ @@ -66,7 +54,6 @@ export class PersonManager implements ISQLPersonManager { return this.persons.find((p): boolean => p.name === name); } - public async saveAll(names: string[]): Promise { const toSave: { name: string }[] = []; const connection = await SQLConnection.getConnection(); @@ -90,12 +77,21 @@ export class PersonManager implements ISQLPersonManager { } - public async onGalleryIndexUpdate(): Promise { await this.updateCounts(); await this.updateSamplePhotos(); + await this.loadAll(); } + private async loadAll(): Promise { + const connection = await SQLConnection.getConnection(); + const personRepository = connection.getRepository(PersonEntry); + this.persons = await personRepository.find({ + relations: ['sampleRegion', + 'sampleRegion.media', + 'sampleRegion.media.directory'] + }); + } private async updateCounts(): Promise { const connection = await SQLConnection.getConnection();