From 1574f8e9f9eb7c41b9cda31fd1cd4765ee181a15 Mon Sep 17 00:00:00 2001 From: Kevin Franklin Kim Date: Thu, 17 Oct 2024 10:59:45 +0200 Subject: [PATCH] fix: handle not exists --- pkg/ownbrew/ownbrew.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/ownbrew/ownbrew.go b/pkg/ownbrew/ownbrew.go index 207333c..648d94e 100644 --- a/pkg/ownbrew/ownbrew.go +++ b/pkg/ownbrew/ownbrew.go @@ -221,9 +221,12 @@ func (o *Ownbrew) cellarFilename(name, version string) (string, error) { ) info, err := os.Stat(ret) - if err != nil && !errors.Is(err, os.ErrNotExist) { + if errors.Is(err, os.ErrNotExist) { + return ret, nil + } else if err != nil { return "", errors.Wrap(err, "failed to retrieve file info") } + if info.IsDir() { ret = path.Join(ret, name) }