Skip to content
New issue

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

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

Already on GitHub? # to your account

Migrate preferences only if necessary #748

Merged
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
12 changes: 7 additions & 5 deletions server/src/main/kotlin/suwayomi/tachidesk/server/ServerSetup.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ import java.io.File
import java.security.Security
import java.util.Locale
import java.util.prefs.Preferences
import kotlin.io.path.exists
import kotlin.io.path.outputStream

private val logger = KotlinLogging.logger {}

Expand Down Expand Up @@ -217,9 +215,13 @@ fun applicationSetup() {
}
}, ignoreInitialValue = false)

val preferences = Preferences.userRoot().node("suwayomi/tachidesk")
migratePreferences(null, preferences)
preferences.removeNode()
val prefRootNode = "suwayomi/tachidesk"
val isMigrationRequired = Preferences.userRoot().nodeExists(prefRootNode)
if (isMigrationRequired) {
val preferences = Preferences.userRoot().node(prefRootNode)
migratePreferences(null, preferences)
preferences.removeNode()
}

// Disable jetty's logging
System.setProperty("org.eclipse.jetty.util.log.announce", "false")
Expand Down