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:
parent
777124d415
commit
de5c80df64
1 changed files with 11 additions and 3 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue