@@ -89,7 +89,7 @@ func (cli *Client) fetchAppState(ctx context.Context, name appstate.WAPatchName,
8989 }
9090 if fullSync {
9191 cli .Log .Debugf ("Full sync of app state %s completed. Current version: %d" , name , state .Version )
92- eventsToDispatch = append (eventsToDispatch , & events.AppStateSyncComplete {Name : name })
92+ eventsToDispatch = append (eventsToDispatch , & events.AppStateSyncComplete {Name : name , Version : state . Version })
9393 } else {
9494 cli .Log .Debugf ("Synced app state %s from version %d to %d" , name , version , state .Version )
9595 }
@@ -118,11 +118,12 @@ func (cli *Client) handleAppStateRecovery(
118118 return true
119119 }
120120 name := appstate .WAPatchName (snapshot .GetCollectionName ())
121+ version := snapshot .GetVersion ().GetVersion ()
121122 currentVersion , _ , err := cli .Store .AppState .GetAppStateVersion (ctx , string (name ))
122123 if err != nil {
123124 cli .Log .Errorf ("Failed to get current app state %s version for %s: %v" , name , reqID , err )
124125 return true
125- } else if currentVersion >= snapshot . GetVersion (). GetVersion () {
126+ } else if currentVersion >= version {
126127 cli .Log .Infof ("Ignoring app state recovery response for %s as current version %d is newer than or equal to recovery version %d" , reqID , currentVersion , snapshot .GetVersion ().GetVersion ())
127128 return true
128129 }
@@ -137,14 +138,14 @@ func (cli *Client) handleAppStateRecovery(
137138 cli .Log .Warnf ("Failed to collect app state events for %s: %v" , reqID , err )
138139 return true
139140 }
140- eventsToDispatch = append (eventsToDispatch , & events.AppStateSyncComplete {Name : name })
141+ eventsToDispatch = append (eventsToDispatch , & events.AppStateSyncComplete {Name : name , Version : version , Recovery : true })
141142 for _ , evt := range eventsToDispatch {
142143 handlerFailed := cli .dispatchEvent (evt )
143144 if handlerFailed {
144145 return false
145146 }
146147 }
147- cli .Log .Debugf ("Finished handling app state recovery response for %s (%s to v%d)" , reqID , name , snapshot . GetVersion (). GetVersion () )
148+ cli .Log .Debugf ("Finished handling app state recovery response for %s (%s to v%d)" , reqID , name , version )
148149 return true
149150}
150151
0 commit comments