1
0
Fork 0
mirror of https://github.com/anyproto/any-sync.git synced 2025-06-08 05:57:03 +09:00

store config if merged

This commit is contained in:
Anatolii Smolianinov 2024-09-17 15:19:31 +02:00
parent 777124d415
commit de5c80df64
No known key found for this signature in database
GPG key ID: 5E259D1D468B99F4

View file

@ -99,7 +99,7 @@ func mergeCoordinatorAddrs(appConfig *Configuration, lastStored *Configuration)
}
}
} else {
// append a whole node to stored config
// append a whole node to the stored config
mustRewriteLocalConfig = true
lastStored.Nodes = append(lastStored.Nodes, *appNode)
}
@ -118,10 +118,18 @@ func (s *service) Init(a *app.App) (err error) {
if err == ErrConfigurationNotFound {
lastStored = s.config
err = nil
} else {
// merge coordinator nodes from app config to lasStored to have up-to-date coordinator
mustRewriteLocalConfig := mergeCoordinatorAddrs(&s.config, &lastStored)
if mustRewriteLocalConfig {
// saving last configuration if changed, which also triggers Configuration.Id change
err = s.saveAndSetLastConfiguration(context.Background(), lastStored)
if err != nil {
return
}
}
}
mergeCoordinatorAddrs(&s.config, &lastStored)
var updatePeriodSec = 600
if confUpd, ok := a.MustComponent("config").(ConfigUpdateGetter); ok && confUpd.GetNodeConfUpdateInterval() > 0 {
updatePeriodSec = confUpd.GetNodeConfUpdateInterval()