From 8a0c6040916e74fd0f9563ef3658ced5aa38b5d4 Mon Sep 17 00:00:00 2001 From: Code by Ben Date: Fri, 6 Dec 2024 16:10:42 +1100 Subject: [PATCH] clear readdir after use. --- handler/app/dirs.go | 1 + handler/html3/template.go | 4 +++- handler/htmx/template.go | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/handler/app/dirs.go b/handler/app/dirs.go index 18f158ce..592a902e 100644 --- a/handler/app/dirs.go +++ b/handler/app/dirs.go @@ -464,6 +464,7 @@ func (dir Dirs) assets(nameDir, unid string) map[string][2]string { } } } + clear(files) return matches } diff --git a/handler/html3/template.go b/handler/html3/template.go index 2229d11b..8b8bfebf 100644 --- a/handler/html3/template.go +++ b/handler/html3/template.go @@ -26,7 +26,9 @@ const ( func emptyFS(fs embed.FS) bool { entries, err := fs.ReadDir(".") - return err != nil || len(entries) == 0 + result := err != nil || len(entries) == 0 + clear(entries) + return result } // GlobTo returns the path to the template file. diff --git a/handler/htmx/template.go b/handler/htmx/template.go index 3667dbc1..c26a4bf2 100644 --- a/handler/htmx/template.go +++ b/handler/htmx/template.go @@ -25,7 +25,9 @@ func GlobTo(name string) string { func emptyFS(fs embed.FS) bool { entries, err := fs.ReadDir(".") - return err != nil || len(entries) == 0 + result := err != nil || len(entries) == 0 + clear(entries) + return result } // Templates returns a map of the templates.