Skip to content

Commit

Permalink
fix: deserialize state
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaiSviridov committed Jun 12, 2023
1 parent 23f9a7b commit f45366b
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions core/src/main/kotlin/loader/gerrit/LoaderChanges.kt
Original file line number Diff line number Diff line change
Expand Up @@ -74,25 +74,22 @@ class LoaderChanges(
private val errorsChangesDir = File(errorsDir, "changes")
private val errorsCommentsDir = File(errorsDir, "comments")
private val stateOfLoadFile = File(resultDir, "state")

private val client = ClientGerritREST()
private val json = ClientGerritREST.json
private val stateOfLoad: StateOfLoad

private val stateOfLoad = run {
init {
val default = StateOfLoad(
Parameters(
baseUrl
)
)
return@run if (stateOfLoadFile.exists()) {
// val prevState = json.decodeFromString<StateOfLoad>(stateOfLoadFile.readText())
// if (prevState.parameters != default.parameters) default else prevState
default
stateOfLoad = if (stateOfLoadFile.exists()) {
val prevState = json.decodeFromString<StateOfLoad>(stateOfLoadFile.readText())
if (prevState.parameters != default.parameters) default else prevState
} else default

}

private val json = ClientGerritREST.json

suspend fun loadByIds() {
changesDir.mkdirs()
commentsDir.mkdirs()
Expand Down

0 comments on commit f45366b

Please sign in to comment.