mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-11-17 14:57:27 +00:00
fix(api-key): check usage log rows close
This commit is contained in:
1 parent
e0d149d511
commit
7a11b39d6d
1 file changed
+6
-2
@@ -462,7 +462,7 @@ func (r *apiKeyRepository) attachLastUsedIPs(ctx context.Context, keys []service
|
|||||||
return nil
|
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 {
|
if len(apiKeyIDs) == 0 || r.sql == nil {
|
||||||
return map[int64]string{}, nil
|
return map[int64]string{}, nil
|
||||||
}
|
}
|
||||||
@@ -472,7 +472,11 @@ func (r *apiKeyRepository) latestUsageLogIPs(ctx context.Context, apiKeyIDs []in
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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))
|
out := make(map[int64]string, len(apiKeyIDs))
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
|
|||||||
Reference in new issue
Block a user