Skip to content

Commit

Permalink
add configuration key to force the last modified time of directories (c…
Browse files Browse the repository at this point in the history
…loses #37)
  • Loading branch information
gotson committed Dec 30, 2019
1 parent 3095f08 commit d67ad41
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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?

Expand Down
1 change: 1 addition & 0 deletions doc/sample-configuration/unix/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions doc/sample-configuration/windows/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class KomgaProperties {

var librariesScanDirectoryExclusions: List<String> = emptyList()

var filesystemScannerForceDirectoryModifiedTime: Boolean = false

var threads = Threads()

class Threads {
Expand Down

0 comments on commit d67ad41

Please sign in to comment.