1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-22 22:20:54 +00:00

close fs only when fs open without error

panic when close nil filesystem
This commit is contained in:
Ying Zou 2018-11-28 08:55:20 +08:00
parent b0e2bbce2a
commit a5a2471f2c

View File

@ -186,13 +186,13 @@ func BuildTemplate(dir string, files ...string) error {
var err error var err error
fs := beeTemplateFS() fs := beeTemplateFS()
f, err := fs.Open(dir) f, err := fs.Open(dir)
defer f.Close()
if err != nil { if err != nil {
if os.IsNotExist(err) { if os.IsNotExist(err) {
return nil return nil
} }
return errors.New("dir open err") return errors.New("dir open err")
} }
defer f.Close()
beeTemplates, ok := beeViewPathTemplates[dir] beeTemplates, ok := beeViewPathTemplates[dir]
if !ok { if !ok {