Skip to content

Commit

Permalink
Optionally delete existing downloads of new chapters
Browse files Browse the repository at this point in the history
The downloader checks if pages are already downloaded to prevent unnecessary downloads.
However, in case this is e.g. a re-uploaded chapter, this will prevent the new pages from getting downloaded
  • Loading branch information
schroda committed Sep 1, 2024
1 parent 9f49587 commit 6bf7516
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class SettingsMutation {
updateSetting(settings.autoDownloadAheadLimit, serverConfig.autoDownloadNewChaptersLimit) // deprecated
updateSetting(settings.autoDownloadNewChaptersLimit, serverConfig.autoDownloadNewChaptersLimit)
updateSetting(settings.autoDownloadIgnoreReUploads, serverConfig.autoDownloadIgnoreReUploads)
updateSetting(settings.autoDownloadDeleteExistingFiles, serverConfig.autoDownloadDeleteExistingFiles)

// extension
updateSetting(settings.extensionRepos, serverConfig.extensionRepos)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ interface Settings : Node {
val autoDownloadAheadLimit: Int?
val autoDownloadNewChaptersLimit: Int?
val autoDownloadIgnoreReUploads: Boolean?
val autoDownloadDeleteExistingFiles: Boolean?

// extension
val extensionRepos: List<String>?
Expand Down Expand Up @@ -121,6 +122,7 @@ data class PartialSettingsType(
override val autoDownloadAheadLimit: Int?,
override val autoDownloadNewChaptersLimit: Int?,
override val autoDownloadIgnoreReUploads: Boolean?,
override val autoDownloadDeleteExistingFiles: Boolean?,
// extension
override val extensionRepos: List<String>?,
// requests
Expand Down Expand Up @@ -184,6 +186,7 @@ class SettingsType(
override val autoDownloadAheadLimit: Int,
override val autoDownloadNewChaptersLimit: Int,
override val autoDownloadIgnoreReUploads: Boolean?,
override val autoDownloadDeleteExistingFiles: Boolean,
// extension
override val extensionRepos: List<String>,
// requests
Expand Down Expand Up @@ -242,6 +245,7 @@ class SettingsType(
config.autoDownloadNewChaptersLimit.value, // deprecated
config.autoDownloadNewChaptersLimit.value,
config.autoDownloadIgnoreReUploads.value,
config.autoDownloadDeleteExistingFiles.value,
// extension
config.extensionRepos.value,
// requests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,12 @@ object Chapter {
return
}

// The downloader checks if pages are already downloaded to prevent unnecessary downloads. However, in case this
// is e.g. a re-uploaded chapter, this will prevent the new pages from getting downloaded
if (serverConfig.autoDownloadDeleteExistingFiles.value) {
deleteChapters(chapterIdsToDownload)
}

log.info { "download ${chapterIdsToDownload.size} new chapter(s)..." }

DownloadManager.enqueue(EnqueueInput(chapterIdsToDownload))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class ServerConfig(getConfig: () -> Config, val moduleName: String = SERVER_CONF
val excludeEntryWithUnreadChapters: MutableStateFlow<Boolean> by OverrideConfigValue(BooleanConfigAdapter)
val autoDownloadNewChaptersLimit: MutableStateFlow<Int> by OverrideConfigValue(IntConfigAdapter)
val autoDownloadIgnoreReUploads: MutableStateFlow<Boolean> by OverrideConfigValue(BooleanConfigAdapter)
val autoDownloadDeleteExistingFiles: MutableStateFlow<Boolean> by OverrideConfigValue(BooleanConfigAdapter)

// extensions
val extensionRepos: MutableStateFlow<List<String>> by OverrideConfigValues(StringConfigAdapter)
Expand Down
1 change: 1 addition & 0 deletions server/src/main/resources/server-reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ server.autoDownloadNewChapters = false # if new chapters that have been retrieve
server.excludeEntryWithUnreadChapters = true # ignore automatic chapter downloads of entries with unread chapters
server.autoDownloadNewChaptersLimit = 0 # 0 to disable it - how many unread downloaded chapters should be available - if the limit is reached, new chapters won't be downloaded automatically. this limit will also be applied to the auto download of new chapters on an update
server.autoDownloadIgnoreReUploads = false # decides if re-uploads should be ignored during auto download of new chapters
server.autoDownloadDeleteExistingFiles = false # WARNING: this can cause a lot of downloads in case the app incorrectly detects "new" chapters due to a source changing chapter urls - delete existing downloads for new chapters to prevent pages from getting detected as already downloaded due to outdated pages of the existing download.

# extension repos
server.extensionRepos = [
Expand Down

0 comments on commit 6bf7516

Please sign in to comment.