add configuration key to force the last modified time of directories (closes #37)

This commit is contained in:
Gauthier Roebroeck 2019-12-30 11:42:44 +08:00
parent 3095f08c5e
commit d67ad41e8d
5 changed files with 12 additions and 2 deletions

View File

@ -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?

View File

@ -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

View File

@ -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

View File

@ -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<Series>
@ -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()

View File

@ -13,6 +13,8 @@ class KomgaProperties {
var librariesScanDirectoryExclusions: List<String> = emptyList()
var filesystemScannerForceDirectoryModifiedTime: Boolean = false
var threads = Threads()
class Threads {