Remove 1 or 2 hour library updates to avoid DDoSing sources

(cherry picked from commit 569df39fb88e534fa0deb5b9a412f84936006859)

# Conflicts:
#	app/build.gradle.kts
This commit is contained in:
arkon 2021-05-22 11:52:28 -04:00 committed by Jobobby04
parent 1389649553
commit eaa2bb22ed
4 changed files with 16 additions and 10 deletions

View File

@ -179,6 +179,14 @@ object Migrations {
remove("pref_default_viewer_key")
}
}
if (oldVersion < 61) {
// Handle removed every 1 or 2 hour library updates
val updateInterval = preferences.libraryUpdateInterval().get()
if (updateInterval == 1 || updateInterval == 2) {
preferences.libraryUpdateInterval().set(3)
LibraryUpdateJob.setupTask(context, 3)
}
}
return true
}

View File

@ -150,8 +150,6 @@ class SettingsLibraryController : SettingsController() {
titleRes = R.string.pref_library_update_interval
entriesRes = arrayOf(
R.string.update_never,
R.string.update_1hour,
R.string.update_2hour,
R.string.update_3hour,
R.string.update_4hour,
R.string.update_6hour,
@ -161,7 +159,7 @@ class SettingsLibraryController : SettingsController() {
R.string.update_48hour,
R.string.update_weekly
)
entryValues = arrayOf("0", "1", "2", "3", "4", "6", "8", "12", "24", "48", "168")
entryValues = arrayOf("0", "3", "4", "6", "8", "12", "24", "48", "168")
defaultValue = "24"
summary = "%s"

View File

@ -276,12 +276,14 @@ object EXHMigrations {
)
}
if (oldVersion under 18) {
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
val readerTheme = prefs.getInt("pref_reader_theme_key", 3)
val readerTheme = preferences.readerTheme().get()
if (readerTheme == 4) {
prefs.edit {
putInt("pref_reader_theme_key", 3)
preferences.readerTheme().set(3)
}
val updateInterval = preferences.libraryUpdateInterval().get()
if (updateInterval == 1 || updateInterval == 2) {
preferences.libraryUpdateInterval().set(3)
LibraryUpdateJob.setupTask(context, 3)
}
}

View File

@ -201,8 +201,6 @@
<string name="pref_category_library_update">Global update</string>
<string name="pref_library_update_interval">Update frequency</string>
<string name="update_never">Manual</string>
<string name="update_1hour">Hourly</string>
<string name="update_2hour">Every 2 hours</string>
<string name="update_3hour">Every 3 hours</string>
<string name="update_4hour">Every 4 hours</string>
<string name="update_6hour">Every 6 hours</string>