diff --git a/backend/middlewares/GalleryMWs.ts b/backend/middlewares/GalleryMWs.ts index 1edac34a..80f5fe39 100644 --- a/backend/middlewares/GalleryMWs.ts +++ b/backend/middlewares/GalleryMWs.ts @@ -14,6 +14,7 @@ import {RandomQuery} from '../model/interfaces/IGalleryManager'; import {MediaDTO} from '../../common/entities/MediaDTO'; import {VideoDTO} from '../../common/entities/VideoDTO'; import {Utils} from '../../common/Utils'; +import {QueryParams} from '../../common/QueryParams'; const LOG_TAG = '[GalleryMWs]'; @@ -32,7 +33,9 @@ export class GalleryMWs { try { const directory = await ObjectManagerRepository.getInstance() - .GalleryManager.listDirectory(directoryName, req.query.knownLastModified, req.query.knownLastScanned); + .GalleryManager.listDirectory(directoryName, + parseInt(req.query[QueryParams.gallery.knownLastModified], 10), + parseInt(req.query[QueryParams.gallery.knownLastScanned], 10)); if (directory == null) { req.resultPipe = new ContentWrapper(null, null, true); diff --git a/backend/model/sql/GalleryManager.ts b/backend/model/sql/GalleryManager.ts index f2a68405..a5021e53 100644 --- a/backend/model/sql/GalleryManager.ts +++ b/backend/model/sql/GalleryManager.ts @@ -94,11 +94,10 @@ export class GalleryManager implements IGalleryManager, ISQLGalleryManager { if (knownLastModified && knownLastScanned && lastModified === knownLastModified && dir.lastScanned === knownLastScanned) { - if (Config.Server.indexing.reIndexingSensitivity === ReIndexingSensitivity.low) { return null; } - if (Date.now() - knownLastScanned <= Config.Server.indexing.cachedFolderTimeout && + if (Date.now() - dir.lastScanned <= Config.Server.indexing.cachedFolderTimeout && Config.Server.indexing.reIndexingSensitivity === ReIndexingSensitivity.medium) { return null; } @@ -349,9 +348,9 @@ export class GalleryManager implements IGalleryManager, ISQLGalleryManager { } await fileRepository.save(metaFilesToSave); await fileRepository.remove(indexedMetaFiles); - }catch (e){ + } catch (e) { throw e; - }finally { + } finally { this.isSaving = false; } } diff --git a/common/QueryParams.ts b/common/QueryParams.ts index 1939eb3e..40327348 100644 --- a/common/QueryParams.ts +++ b/common/QueryParams.ts @@ -11,6 +11,8 @@ export const QueryParams = { }, photo: 'p', sharingKey_short: 'sk', - sharingKey_long: 'sharingKey' + sharingKey_long: 'sharingKey', + knownLastModified: 'knownLastModified', + knownLastScanned: 'knownLastScanned' } }; diff --git a/frontend/app/gallery/gallery.service.ts b/frontend/app/gallery/gallery.service.ts index f607174b..36d1a10b 100644 --- a/frontend/app/gallery/gallery.service.ts +++ b/frontend/app/gallery/gallery.service.ts @@ -66,8 +66,8 @@ export class GalleryService { if (content.directory && content.directory.lastModified && content.directory.lastScanned && !content.directory.isPartial) { - params['knownLastModified'] = content.directory.lastModified; - params['knownLastScanned'] = content.directory.lastScanned; + params[QueryParams.gallery.knownLastModified] = content.directory.lastModified; + params[QueryParams.gallery.knownLastScanned] = content.directory.lastScanned; } try { diff --git a/frontend/app/model/query.service.ts b/frontend/app/model/query.service.ts index ee806781..0be440d9 100644 --- a/frontend/app/model/query.service.ts +++ b/frontend/app/model/query.service.ts @@ -46,8 +46,8 @@ export class QueryService { } if (directory && directory.lastModified && directory.lastScanned && !directory.isPartial) { - params['knownLastModified'] = directory.lastModified; - params['knownLastScanned'] = directory.lastScanned; + params[QueryParams.gallery.knownLastModified] = directory.lastModified; + params[QueryParams.gallery.knownLastScanned] = directory.lastScanned; } return params;