@@ -105,33 +105,37 @@ func (cm *PollingProjectConfigManager) SyncConfig(datafile []byte) {
105105 }
106106
107107 projectConfig , err := datafileprojectconfig .NewDatafileProjectConfig (datafile )
108+
109+ cm .configLock .Lock ()
110+ defer func () {
111+ cm .err = err
112+ cm .configLock .Unlock ()
113+ }()
108114 if err != nil {
109115 cmLogger .Error ("failed to create project config" , err )
116+ return
110117 }
111118
112- cm . configLock . Lock ()
119+ var previousRevision string
113120 if cm .projectConfig != nil {
114- if cm .projectConfig .GetRevision () == projectConfig .GetRevision () {
115- cmLogger .Debug (fmt .Sprintf ("No datafile updates. Current revision number: %s" , cm .projectConfig .GetRevision ()))
116- } else {
117- cmLogger .Debug (fmt .Sprintf ("Received new datafile and updated config. Old revision number: %s. New revision number: %s" , cm .projectConfig .GetRevision (), projectConfig .GetRevision ()))
118- cm .projectConfig = projectConfig
119-
120- if cm .notificationCenter != nil {
121- projectConfigUpdateNotification := notification.ProjectConfigUpdateNotification {
122- Type : notification .ProjectConfigUpdate ,
123- Revision : cm .projectConfig .GetRevision (),
124- }
125- if err = cm .notificationCenter .Send (notification .ProjectConfigUpdate , projectConfigUpdateNotification ); err != nil {
126- cmLogger .Warning ("Problem with sending notification" )
127- }
128- }
121+ previousRevision = cm .projectConfig .GetRevision ()
122+ }
123+ if projectConfig .GetRevision () == previousRevision {
124+ cmLogger .Debug (fmt .Sprintf ("No datafile updates. Current revision number: %s" , cm .projectConfig .GetRevision ()))
125+ return
126+ }
127+ cmLogger .Debug (fmt .Sprintf ("New datafile set with revision: %s. Old revision: %s" , projectConfig .GetRevision (), previousRevision ))
128+ cm .projectConfig = projectConfig
129+
130+ if cm .notificationCenter != nil {
131+ projectConfigUpdateNotification := notification.ProjectConfigUpdateNotification {
132+ Type : notification .ProjectConfigUpdate ,
133+ Revision : cm .projectConfig .GetRevision (),
134+ }
135+ if err = cm .notificationCenter .Send (notification .ProjectConfigUpdate , projectConfigUpdateNotification ); err != nil {
136+ cmLogger .Warning ("Problem with sending notification" )
129137 }
130- } else {
131- cm .projectConfig = projectConfig
132138 }
133- cm .err = err
134- cm .configLock .Unlock ()
135139}
136140
137141func (cm * PollingProjectConfigManager ) start () {
0 commit comments