From d53af51be2bcce90856efc43d1593c2fd27d13b6 Mon Sep 17 00:00:00 2001 From: "Patrik J. Braun" Date: Tue, 11 May 2021 17:39:58 +0200 Subject: [PATCH] Adding preview from sub dirs to freshly scanned photos: #31 --- .travis.yml | 1 - src/backend/model/database/sql/GalleryManager.ts | 10 ++++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index ab807d7a..220c8032 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,5 @@ before_install: - google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost & install: - npm ci - - npm run lint - npm run build after_success: npm run coverage diff --git a/src/backend/model/database/sql/GalleryManager.ts b/src/backend/model/database/sql/GalleryManager.ts index 1963b62b..9f250262 100644 --- a/src/backend/model/database/sql/GalleryManager.ts +++ b/src/backend/model/database/sql/GalleryManager.ts @@ -60,7 +60,13 @@ export class GalleryManager implements IGalleryManager, ISQLGalleryManager { if (dir.lastModified !== lastModified) { Logger.silly(LOG_TAG, 'Reindexing reason: lastModified mismatch: known: ' + dir.lastModified + ', current:' + lastModified); - return ObjectManagers.getInstance().IndexingManager.indexDirectory(relativeDirectoryName); + const ret = await ObjectManagers.getInstance().IndexingManager.indexDirectory(relativeDirectoryName); + for (const subDir of ret.directories) { + if (!subDir.preview) { // if sub directories does not have photos, so cannot show a preview, try get one from DB + await this.fillPreviewFromSubDir(connection, subDir); + } + } + return ret; } @@ -213,7 +219,7 @@ export class GalleryManager implements IGalleryManager, ISQLGalleryManager { return await query.getOne(); } - protected async fillPreviewFromSubDir(connection: Connection, dir: DirectoryEntity): Promise { + protected async fillPreviewFromSubDir(connection: Connection, dir: DirectoryDTO): Promise { dir.media = []; const query = connection .getRepository(MediaEntity)