mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-09-24 16:05:44 +08:00
fix(api-key): check usage log rows close
This commit is contained in:
@@ -462,7 +462,7 @@ func (r *apiKeyRepository) attachLastUsedIPs(ctx context.Context, keys []service
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *apiKeyRepository) latestUsageLogIPs(ctx context.Context, apiKeyIDs []int64) (map[int64]string, error) {
|
||||
func (r *apiKeyRepository) latestUsageLogIPs(ctx context.Context, apiKeyIDs []int64) (result map[int64]string, err error) {
|
||||
if len(apiKeyIDs) == 0 || r.sql == nil {
|
||||
return map[int64]string{}, nil
|
||||
}
|
||||
@@ -472,7 +472,11 @@ func (r *apiKeyRepository) latestUsageLogIPs(ctx context.Context, apiKeyIDs []in
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
defer func() {
|
||||
if closeErr := rows.Close(); closeErr != nil && err == nil {
|
||||
err = closeErr
|
||||
}
|
||||
}()
|
||||
|
||||
out := make(map[int64]string, len(apiKeyIDs))
|
||||
for rows.Next() {
|
||||
|
||||
Reference in New Issue
Block a user