Skip to content

Commit d67ad41

Browse files
committed
add configuration key to force the last modified time of directories (closes #37)
1 parent 3095f08 commit d67ad41

File tree

5 files changed

+12
-2
lines changed

5 files changed

+12
-2
lines changed

Diff for: README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ You can also use some optional configuration keys:
5959

6060
- `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.
6161
- `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.
62-
- `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.
62+
- `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.
63+
- `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).
6364

6465
## What does it do?
6566

Diff for: doc/sample-configuration/unix/application.yml

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ komga:
33
libraries-scan-directory-exclusions: #patterns to exclude directories from the scan
44
- "#recycle" #synology NAS recycle bin
55
- "@eaDir" #synology NAS index/metadata folders
6+
filesystem-scanner-force-directory-modified-time: false #set to true only if newly added books in existing series are not scanned (ie Google Drive)
67
spring:
78
datasource:
89
url: jdbc:h2:./komga-database.h2 #database will be located in the current directory

Diff for: doc/sample-configuration/windows/application.yml

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ komga:
33
libraries-scan-directory-exclusions: #patterns to exclude directories from the scan
44
- "#recycle" #synology NAS recycle bin
55
- "@eaDir" #synology NAS index/metadata folders
6+
filesystem-scanner-force-directory-modified-time: false #set to true only if newly added books in existing series are not scanned (ie Google Drive)
67
spring:
78
datasource:
89
url: jdbc:h2:./komga-database.h2 #database will be located in the current directory

Diff for: komga/src/main/kotlin/org/gotson/komga/domain/service/FileSystemScanner.kt

+6-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ class FileSystemScanner(
3030
logger.info { "Scanning folder: $root" }
3131
logger.info { "Supported extensions: $supportedExtensions" }
3232
logger.info { "Excluded patterns: ${komgaProperties.librariesScanDirectoryExclusions}" }
33+
if (komgaProperties.filesystemScannerForceDirectoryModifiedTime)
34+
logger.info { "Force directory modified time: active" }
3335

3436
lateinit var scannedSeries: List<Series>
3537

@@ -60,7 +62,10 @@ class FileSystemScanner(
6062
Series(
6163
name = dir.fileName.toString(),
6264
url = dir.toUri().toURL(),
63-
fileLastModified = dir.getUpdatedTime(),
65+
fileLastModified =
66+
if (komgaProperties.filesystemScannerForceDirectoryModifiedTime)
67+
maxOf(dir.getUpdatedTime(), books.map { it.fileLastModified }.max()!!)
68+
else dir.getUpdatedTime(),
6469
books = books.toMutableList()
6570
)
6671
}.toList()

Diff for: komga/src/main/kotlin/org/gotson/komga/infrastructure/configuration/KomgaProperties.kt

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ class KomgaProperties {
1313

1414
var librariesScanDirectoryExclusions: List<String> = emptyList()
1515

16+
var filesystemScannerForceDirectoryModifiedTime: Boolean = false
17+
1618
var threads = Threads()
1719

1820
class Threads {

0 commit comments

Comments
 (0)