GODT-2047: Clear last event ID when clearing sync status

This commit is contained in:
James Houlahan
2022-11-17 13:18:47 +00:00
parent fe5e8ce7f7
commit 1e48ab4b9c
5 changed files with 68 additions and 70 deletions

View File

@ -43,9 +43,21 @@ const (
)
// doSync begins syncing the users data.
// It first ensures the latest event ID is known; if not, it fetches it.
// It sends a SyncStarted event and then either SyncFinished or SyncFailed
// depending on whether the sync was successful.
func (user *User) doSync(ctx context.Context) error {
if user.vault.EventID() == "" {
eventID, err := user.client.GetLatestEventID(ctx)
if err != nil {
return fmt.Errorf("failed to get latest event ID: %w", err)
}
if err := user.vault.SetEventID(eventID); err != nil {
return fmt.Errorf("failed to set latest event ID: %w", err)
}
}
start := time.Now()
user.log.WithField("start", start).Info("Beginning user sync")