Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete existing download of new chapters #1022

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -183,7 +185,8 @@ class SettingsType(
)
override val autoDownloadAheadLimit: Int,
override val autoDownloadNewChaptersLimit: Int,
override val autoDownloadIgnoreReUploads: Boolean?,
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
Loading