From f740b71ded607ed5dfc2d06a3f369b11bea28b93 Mon Sep 17 00:00:00 2001 From: Viktor Vassilyev Date: Mon, 5 Nov 2018 21:08:03 +0600 Subject: [PATCH] fix(Template): remove duplicate check open/exists --- template.go | 7 ++----- template_test.go | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/template.go b/template.go index d6af3db0..45d73fa0 100644 --- a/template.go +++ b/template.go @@ -186,16 +186,13 @@ func BuildTemplate(dir string, files ...string) error { fs := beeTemplateFS() f, err := fs.Open(dir) if err != nil { - return errors.New("dir open err") - } - defer f.Close() - - if _, err := f.Stat(); err != nil { if os.IsNotExist(err) { return nil } return errors.New("dir open err") } + defer f.Close() + beeTemplates, ok := beeViewPathTemplates[dir] if !ok { panic("Unknown view path: " + dir) diff --git a/template_test.go b/template_test.go index c8be71c4..2153ef72 100644 --- a/template_test.go +++ b/template_test.go @@ -105,7 +105,7 @@ var user = ` func TestRelativeTemplate(t *testing.T) { dir := "_beeTmp" - os.Mkdir(dir, 0777) + //Just add dir to known viewPaths if err := AddViewPath(dir); err != nil { t.Fatal(err)