Skip to content

Commit

Permalink
Fix whitelist upload batching (#612) (#615)
Browse files Browse the repository at this point in the history
  • Loading branch information
calebroseland authored Apr 19, 2024
1 parent 0abd31d commit 53310b9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions server/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,8 @@ func (a *API) updateWhitelist(w http.ResponseWriter, r *http.Request) {
return
}

a.p.API.LogInfo("Whitelist updated", "size", len(ids))

w.WriteHeader(http.StatusOK)
w.Header().Set("Content-Type", "application/json")
if err := json.NewEncoder(w).Encode(&UpdateWhitelistResult{
Expand Down
3 changes: 2 additions & 1 deletion server/store/sqlstore/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -1006,11 +1006,12 @@ func (s *SQLStore) SetWhitelist(userIDs []string, batchSize int) error {
for i, id := range userIDs {
currentBatch = append(currentBatch, id)
if len(currentBatch) >= batchSize || i == len(userIDs)-1 {
// batch threshold met, or end of list
if err = s.storeUsersInWhitelist(currentBatch, tx); err != nil {
s.api.LogDebug("Error adding batched users to whitelist", "error", err.Error(), "userIds", currentBatch)
return err
}
clear(currentBatch)
currentBatch = nil
}
}

Expand Down

0 comments on commit 53310b9

Please sign in to comment.