diff --git a/src/backend/model/database/GalleryManager.ts b/src/backend/model/database/GalleryManager.ts index 6617c7d1..9f7b43cb 100644 --- a/src/backend/model/database/GalleryManager.ts +++ b/src/backend/model/database/GalleryManager.ts @@ -40,16 +40,26 @@ export class GalleryManager { const directoryPath = GalleryManager.parseRelativeDirePath( relativeDirectoryName ); + const connection = await SQLConnection.getConnection(); - const stat = fs.statSync( - path.join(ProjectPath.ImageFolder, relativeDirectoryName) - ); - const lastModified = DiskMangerWorker.calcLastModified(stat); - - const dir = await this.getDirIdAndTime(connection, directoryPath.name, directoryPath.parent); + if (dir && dir.lastScanned != null) { + // Return as soon as possible without touching the original data source (hdd) + // See https://github.com/bpatrik/pigallery2/issues/613 + if ( + Config.Indexing.reIndexingSensitivity === + ReIndexingSensitivity.never + ) { + return null; + } + + const stat = fs.statSync( + path.join(ProjectPath.ImageFolder, relativeDirectoryName) + ); + const lastModified = DiskMangerWorker.calcLastModified(stat); + // If it seems that the content did not change, do not work on it if ( knownLastModified && diff --git a/src/common/config/private/PrivateConfig.ts b/src/common/config/private/PrivateConfig.ts index 3c71e289..9cd3d269 100644 --- a/src/common/config/private/PrivateConfig.ts +++ b/src/common/config/private/PrivateConfig.ts @@ -64,9 +64,12 @@ export enum SQLLogLevel { } export enum ReIndexingSensitivity { - low = 1, - medium = 2, - high = 3, + // Order is important. It also used to do relative comparison. + // Keep space between items for future + never = 10, + low = 20, + medium = 30, + high = 40, } export enum FFmpegPresets { @@ -443,7 +446,7 @@ export class ServerIndexingConfig { name: $localize`Folder reindexing sensitivity`, priority: ConfigPriority.advanced }, - description: $localize`Set the reindexing sensitivity. High value check the folders for change more often.` + description: $localize`Set the reindexing sensitivity. High value check the folders for change more often. Setting to never only indexes if never indexed or explicit running the Indexing Job.` }) reIndexingSensitivity: ReIndexingSensitivity = ReIndexingSensitivity.low; @ConfigProperty({ diff --git a/src/frontend/app/ui/EnumTranslations.ts b/src/frontend/app/ui/EnumTranslations.ts index 571d8192..3a7a062d 100644 --- a/src/frontend/app/ui/EnumTranslations.ts +++ b/src/frontend/app/ui/EnumTranslations.ts @@ -39,6 +39,7 @@ EnumTranslations[MapProviders[MapProviders.OpenStreetMap]] = $localize`OpenStree EnumTranslations[MapProviders[MapProviders.Mapbox]] = $localize`Mapbox`; +EnumTranslations[ReIndexingSensitivity[ReIndexingSensitivity.never]] = $localize`never`; EnumTranslations[ReIndexingSensitivity[ReIndexingSensitivity.low]] = $localize`low`; EnumTranslations[ReIndexingSensitivity[ReIndexingSensitivity.high]] = $localize`high`; EnumTranslations[ReIndexingSensitivity[ReIndexingSensitivity.medium]] = $localize`medium`;