Make sure to always close directory fd

This commit is contained in:
Jakob Borg 2013-12-30 19:30:59 -05:00
parent ec0489a8ea
commit 71d50a50f4

View File

@ -110,12 +110,14 @@ func Walk(dir string, model *Model, followSymlinks bool) []File {
warnln(err) warnln(err)
return files return files
} }
defer d.Close()
fis, err := d.Readdir(-1) fis, err := d.Readdir(-1)
if err != nil { if err != nil {
warnln(err) warnln(err)
return files return files
} }
d.Close()
for _, fi := range fis { for _, fi := range fis {
if fi.Mode()&os.ModeSymlink != 0 { if fi.Mode()&os.ModeSymlink != 0 {
err := filepath.Walk(path.Join(dir, fi.Name())+"/", fn) err := filepath.Walk(path.Join(dir, fi.Name())+"/", fn)