Fix deferInLoop error (#10387)
Signed-off-by: z1cheng <imchench@gmail.com>
This commit is contained in:
parent
fb7f92a7d5
commit
93e006c2ce
1 changed files with 11 additions and 12 deletions
|
@ -179,20 +179,19 @@ func downloadDatabase(dbName string) error {
|
||||||
if !strings.HasSuffix(header.Name, mmdbFile) {
|
if !strings.HasSuffix(header.Name, mmdbFile) {
|
||||||
continue
|
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))
|
defer outFile.Close()
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
//nolint:gocritic // TODO: will fix it on a followup PR
|
if _, err := io.CopyN(outFile, tarReader, header.Size); err != nil {
|
||||||
defer outFile.Close()
|
return err
|
||||||
|
}
|
||||||
if _, err := io.CopyN(outFile, tarReader, header.Size); err != nil {
|
return nil
|
||||||
return err
|
}()
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue