From 1b4aa6e0ffd95d8de2cd1a8ffb9e097a8fedea1a Mon Sep 17 00:00:00 2001 From: "Richard T. Carback III" <rick.carback@gmail.com> Date: Thu, 24 Feb 2022 23:23:51 +0000 Subject: [PATCH] Handle nil update callback --- xxmutils/restoreContacts.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/xxmutils/restoreContacts.go b/xxmutils/restoreContacts.go index c35bd141b..7653089d8 100644 --- a/xxmutils/restoreContacts.go +++ b/xxmutils/restoreContacts.go @@ -87,6 +87,13 @@ func RestoreContactsFromBackup(backupPartnerIDs []byte, client *bindings.Client, maxChanSize := 10000 restoreTimeout := time.Duration(30 * time.Second) + update := func(numFound, numRestored, total int, err string) { + if updatesCb != nil { + updatesCb.RestoreContactsCallback(numFound, numRestored, + total, err) + } + } + api := client.GetInternalClient() store := stateStore{ @@ -112,7 +119,7 @@ func RestoreContactsFromBackup(backupPartnerIDs []byte, client *bindings.Client, } // Before we start, report initial state - updatesCb.RestoreContactsCallback(lookupCnt, resetCnt, totalCnt, "") + update(lookupCnt, resetCnt, totalCnt, "") // Initialize channels chanSize := int(math.Min(float64(maxChanSize), float64(len(idList)))) @@ -183,8 +190,7 @@ func RestoreContactsFromBackup(backupPartnerIDs []byte, client *bindings.Client, if resetCnt == totalCnt { done = true } - updatesCb.RestoreContactsCallback(lookupCnt, resetCnt, totalCnt, - "") + update(lookupCnt, resetCnt, totalCnt, "") } // Cleanup -- GitLab