Skip to content
Snippets Groups Projects
Commit 49150090 authored by Richard T. Carback III's avatar Richard T. Carback III
Browse files

Merge branch 'hotfix/reportwitherror' into 'release'

Add the restore error operation to the report object

See merge request !182
parents 92fb510c 7eb68b7e
No related branches found
No related tags found
3 merge requests!231Revert "Update store to print changes to the partners list",!187Xx 3829/triggers,!182Add the restore error operation to the report object
...@@ -29,6 +29,7 @@ type RestoreContactsReport struct { ...@@ -29,6 +29,7 @@ type RestoreContactsReport struct {
restored []*id.ID restored []*id.ID
failed []*id.ID failed []*id.ID
errs []error errs []error
restErr error
} }
// LenRestored returns the length of ID's restored. // LenRestored returns the length of ID's restored.
...@@ -56,6 +57,14 @@ func (r *RestoreContactsReport) GetErrorAt(index int) string { ...@@ -56,6 +57,14 @@ func (r *RestoreContactsReport) GetErrorAt(index int) string {
return r.errs[index].Error() return r.errs[index].Error()
} }
// GetRestoreContactsError returns an error string. Empty if no error.
func (r *RestoreContactsReport) GetRestoreContactsError() string {
if r.restErr == nil {
return ""
}
return r.restErr.Error()
}
// RestoreContactsFromBackup takes as input the jason output of the // RestoreContactsFromBackup takes as input the jason output of the
// `NewClientFromBackup` function, unmarshals it into IDs, looks up // `NewClientFromBackup` function, unmarshals it into IDs, looks up
// each ID in user discovery, and initiates a session reset request. // each ID in user discovery, and initiates a session reset request.
...@@ -65,8 +74,8 @@ func (r *RestoreContactsReport) GetErrorAt(index int) string { ...@@ -65,8 +74,8 @@ func (r *RestoreContactsReport) GetErrorAt(index int) string {
// the mobile phone apps and are not intended to be part of the xxDK. It // the mobile phone apps and are not intended to be part of the xxDK. It
// should be treated as internal functions specific to the phone apps. // should be treated as internal functions specific to the phone apps.
func RestoreContactsFromBackup(backupPartnerIDs []byte, client *Client, func RestoreContactsFromBackup(backupPartnerIDs []byte, client *Client,
udManager *UserDiscovery, updatesCb RestoreContactsUpdater) ( udManager *UserDiscovery,
*RestoreContactsReport, error) { updatesCb RestoreContactsUpdater) *RestoreContactsReport {
restored, failed, errs, err := xxmutils.RestoreContactsFromBackup( restored, failed, errs, err := xxmutils.RestoreContactsFromBackup(
backupPartnerIDs, &client.api, udManager.ud, updatesCb) backupPartnerIDs, &client.api, udManager.ud, updatesCb)
...@@ -75,6 +84,7 @@ func RestoreContactsFromBackup(backupPartnerIDs []byte, client *Client, ...@@ -75,6 +84,7 @@ func RestoreContactsFromBackup(backupPartnerIDs []byte, client *Client,
restored: restored, restored: restored,
failed: failed, failed: failed,
errs: errs, errs: errs,
}, err restErr: err,
}
} }
...@@ -149,13 +149,18 @@ func RestoreContactsFromBackup(backupPartnerIDs []byte, client *api.Client, ...@@ -149,13 +149,18 @@ func RestoreContactsFromBackup(backupPartnerIDs []byte, client *api.Client,
} }
// Cleanup // Cleanup
// lookupCh -> foundCh -> resetContactCh -> restoredCh
close(lookupCh) close(lookupCh)
close(resetContactCh)
close(failCh)
// Now wait for subroutines to close before closing their output chans // Now wait for subroutines to close before closing their output chans
lcWg.Wait() lcWg.Wait()
// Close input to reset chan after lookup is done to avoid writes after
// close
close(foundCh) close(foundCh)
close(resetContactCh)
rsWg.Wait() rsWg.Wait()
// failCh is closed after exit of the threads to avoid writes after
// close
close(failCh)
close(restoredCh) close(restoredCh)
failWg.Wait() failWg.Wait()
...@@ -185,8 +190,6 @@ func LookupContacts(in chan *id.ID, out chan *contact.Contact, ...@@ -185,8 +190,6 @@ func LookupContacts(in chan *id.ID, out chan *contact.Contact,
continue continue
} }
jww.WARN.Printf("could not lookup %s: %v", lookupID, err) jww.WARN.Printf("could not lookup %s: %v", lookupID, err)
// Retry later
in <- lookupID
} }
} }
...@@ -207,9 +210,9 @@ func ResetSessions(in, out chan *contact.Contact, failCh chan failure, ...@@ -207,9 +210,9 @@ func ResetSessions(in, out chan *contact.Contact, failCh chan failure,
continue continue
} }
// If an error, figure out if I should report or retry // If an error, figure out if I should report or retry
// Note: Always retry here for now. // Note: Always fail here for now.
jww.WARN.Printf("could not reset %s: %v", c.ID, err) jww.WARN.Printf("could not reset %s: %v", c.ID, err)
in <- c failCh <- failure{ID: c.ID, Err: err}
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment