From 8b9195e3e3506d576b39a23ca646c260dfacc808 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Wed, 1 May 2024 16:23:08 +0200 Subject: chore(gonf): fix errcheck and shadow errors --- pkg/utils.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'pkg/utils.go') diff --git a/pkg/utils.go b/pkg/utils.go index c3301f2..3920737 100644 --- a/pkg/utils.go +++ b/pkg/utils.go @@ -28,15 +28,19 @@ func FilterSlice[T any](slice *[]T, predicate func(T) bool) { func makeDirectoriesHierarchy(dir string, perms *Permissions) (Status, error) { if _, err := os.Lstat(dir); err != nil { if errors.Is(err, fs.ErrNotExist) { - if status, err := makeDirectoriesHierarchy(filepath.Dir(dir), perms); err != nil { - return status, err + if _, err = makeDirectoriesHierarchy(filepath.Dir(dir), perms); err != nil { + return BROKEN, err + } + var m int + if m, err = perms.mode.Int(); err != nil { + return BROKEN, err + } + if err = os.Mkdir(dir, fs.FileMode(m)); err != nil { + return BROKEN, err } - m, err := perms.mode.Int() - if err != nil { + if _, err = perms.resolve(dir); err != nil { return BROKEN, err } - os.Mkdir(dir, fs.FileMode(m)) - perms.resolve(dir) return REPAIRED, nil } else { return BROKEN, err -- cgit v1.2.3