Skip to content

Commit

Permalink
Fix deferInLoop error (#10387)
Browse files Browse the repository at this point in the history
Signed-off-by: z1cheng <imchench@gmail.com>
  • Loading branch information
z1cheng committed Sep 10, 2023
1 parent fb7f92a commit 93e006c
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions internal/nginx/maxmind.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,20 +179,19 @@ func downloadDatabase(dbName string) error {
if !strings.HasSuffix(header.Name, mmdbFile) {
continue
}
return func() error {
outFile, err := os.Create(path.Join(geoIPPath, mmdbFile))
if err != nil {
return err
}

outFile, err := os.Create(path.Join(geoIPPath, mmdbFile))
if err != nil {
return err
}

//nolint:gocritic // TODO: will fix it on a followup PR
defer outFile.Close()

if _, err := io.CopyN(outFile, tarReader, header.Size); err != nil {
return err
}
defer outFile.Close()

return nil
if _, err := io.CopyN(outFile, tarReader, header.Size); err != nil {
return err
}
return nil
}()
}
}

Expand Down

0 comments on commit 93e006c

Please sign in to comment.