Skip to content

Commit

Permalink
EPMDJ-3407 Fixed restoring of build diff (parent build reference) aft…
Browse files Browse the repository at this point in the history
…er server restart.
  • Loading branch information
viktorbll committed Sep 7, 2020
1 parent 3f39396 commit b1940f4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
12 changes: 9 additions & 3 deletions core/src/main/kotlin/agent/State.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,17 @@ internal class AgentData(
)

suspend fun initBuild(version: String) {
val agentBuild = buildManager.init(version)
store(agentBuild)
if (buildManager.builds.none()) {
loadStoredData()
}
buildManager[version] ?: run {
val agentBuild = buildManager.init(version)
store(agentBuild)
}
}

internal suspend fun initClasses() {
kotlin.runCatching { }
val addedClasses: List<ByteArray> = buildManager.collectClasses()
logger.debug { "Saving ${addedClasses.size} classes..." }
measureTime {
Expand Down Expand Up @@ -102,7 +108,7 @@ internal class AgentData(
logger.debug { "Saved build ${agentBuild.id}." }
}

suspend fun loadStoredData() = storeClient.findById<AgentDataSummary>(agentId)?.let { summary ->
private suspend fun loadStoredData() = storeClient.findById<AgentDataSummary>(agentId)?.let { summary ->
logger.debug { "Loading data for $agentId..." }
_settings.value = summary.settings
val classBytes: Map<String, ByteArray> = storeClient.findById<StoredCodeData>(agentId)?.let {
Expand Down
1 change: 0 additions & 1 deletion core/src/main/kotlin/endpoints/AgentManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ class AgentManager(override val kodein: Kodein) : KodeinAware {
val info = storedInfo ?: config.toAgentInfo()
val entry = AgentEntry(info, session)
agentStorage.put(id, entry)
adminData.loadStoredData()
storedInfo?.initPlugins(entry)
app.launch {
storedInfo?.sync(needSync) // sync only existing info!
Expand Down

0 comments on commit b1940f4

Please sign in to comment.