diff --git a/README.md b/README.md index e284a7174..8738ae26c 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,8 @@ You can also use some optional configuration keys: - `KOMGA_LIBRARIES_SCAN_CRON` / `komga.libraries-scan-cron`: a [Spring cron expression](https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/scheduling/support/CronSequenceGenerator.html) for libraries periodic rescans. `0 0 * * * ?` will rescan every hour. `0 */15 * * * ?` will rescan every 15 minutes. Defaults to `0 */15 * * * ?` in `prod` profile. - `KOMGA_THREADS_PARSE` / `komga.threads.parse`: the number of worker threads used for book parsing. Defaults to `2`. You can experiment to get better performance. -- `KOMGA_LIBRARIES_SCAN_DIRECTORY_EXCLUSIONS` / `komga.libraries-scan-directory-exclusions`: a list of patterns to exclude directories from the scan. If the full path contains any of the patterns, the directory will be ignored. If using the environment variable form use a comma-separated list. +- `KOMGA_LIBRARIES_SCAN_DIRECTORY_EXCLUSIONS` / `komga.libraries-scan-directory-exclusions`: a list of patterns to exclude directories from the scan. If the full path contains any of the patterns, the directory will be ignored. If using the environment variable form use a comma-separated list. +- `KOMGA_FILESYSTEM_SCANNER_FORCE_DIRECTORY_MODIFIED_TIME` / `komga.filesystem-scanner-force-directory-modified-time`: if set to `true`, it will force the last modified time of a directory as the maximum from its own last modified time and the last modified time from all the books inside the directory. This should be used only if your filesystem does not update the last modified time of a directory when files inside it are modified (Google Drive for instance). ## What does it do? diff --git a/doc/sample-configuration/unix/application.yml b/doc/sample-configuration/unix/application.yml index 15175006e..207e2d52b 100644 --- a/doc/sample-configuration/unix/application.yml +++ b/doc/sample-configuration/unix/application.yml @@ -3,6 +3,7 @@ komga: libraries-scan-directory-exclusions: #patterns to exclude directories from the scan - "#recycle" #synology NAS recycle bin - "@eaDir" #synology NAS index/metadata folders + filesystem-scanner-force-directory-modified-time: false #set to true only if newly added books in existing series are not scanned (ie Google Drive) spring: datasource: url: jdbc:h2:./komga-database.h2 #database will be located in the current directory diff --git a/doc/sample-configuration/windows/application.yml b/doc/sample-configuration/windows/application.yml index cdcab175b..0c64c8680 100644 --- a/doc/sample-configuration/windows/application.yml +++ b/doc/sample-configuration/windows/application.yml @@ -3,6 +3,7 @@ komga: libraries-scan-directory-exclusions: #patterns to exclude directories from the scan - "#recycle" #synology NAS recycle bin - "@eaDir" #synology NAS index/metadata folders + filesystem-scanner-force-directory-modified-time: false #set to true only if newly added books in existing series are not scanned (ie Google Drive) spring: datasource: url: jdbc:h2:./komga-database.h2 #database will be located in the current directory diff --git a/komga/src/main/kotlin/org/gotson/komga/domain/service/FileSystemScanner.kt b/komga/src/main/kotlin/org/gotson/komga/domain/service/FileSystemScanner.kt index 4e8fc2c3d..0334e4727 100644 --- a/komga/src/main/kotlin/org/gotson/komga/domain/service/FileSystemScanner.kt +++ b/komga/src/main/kotlin/org/gotson/komga/domain/service/FileSystemScanner.kt @@ -30,6 +30,8 @@ class FileSystemScanner( logger.info { "Scanning folder: $root" } logger.info { "Supported extensions: $supportedExtensions" } logger.info { "Excluded patterns: ${komgaProperties.librariesScanDirectoryExclusions}" } + if (komgaProperties.filesystemScannerForceDirectoryModifiedTime) + logger.info { "Force directory modified time: active" } lateinit var scannedSeries: List @@ -60,7 +62,10 @@ class FileSystemScanner( Series( name = dir.fileName.toString(), url = dir.toUri().toURL(), - fileLastModified = dir.getUpdatedTime(), + fileLastModified = + if (komgaProperties.filesystemScannerForceDirectoryModifiedTime) + maxOf(dir.getUpdatedTime(), books.map { it.fileLastModified }.max()!!) + else dir.getUpdatedTime(), books = books.toMutableList() ) }.toList() diff --git a/komga/src/main/kotlin/org/gotson/komga/infrastructure/configuration/KomgaProperties.kt b/komga/src/main/kotlin/org/gotson/komga/infrastructure/configuration/KomgaProperties.kt index 8a360075b..f7da14be4 100644 --- a/komga/src/main/kotlin/org/gotson/komga/infrastructure/configuration/KomgaProperties.kt +++ b/komga/src/main/kotlin/org/gotson/komga/infrastructure/configuration/KomgaProperties.kt @@ -13,6 +13,8 @@ class KomgaProperties { var librariesScanDirectoryExclusions: List = emptyList() + var filesystemScannerForceDirectoryModifiedTime: Boolean = false + var threads = Threads() class Threads {