From: Matt Joiner Date: Wed, 1 Sep 2021 06:17:23 +0000 (+1000) Subject: Fix info name when building from . and .. X-Git-Tag: v1.31.0~3 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=aa3b8644263aff11eb98fccbf63c0cdd5895c97a;p=btrtrc.git Fix info name when building from . and .. --- diff --git a/metainfo/info.go b/metainfo/info.go index 1c2d0b85..6b251884 100644 --- a/metainfo/info.go +++ b/metainfo/info.go @@ -26,7 +26,15 @@ type Info struct { // This is a helper that sets Files and Pieces from a root path and its // children. func (info *Info) BuildFromFilePath(root string) (err error) { - info.Name = filepath.Base(root) + info.Name = func() string { + b := filepath.Base(root) + switch b { + case ".", "..", string(filepath.Separator): + return "" + default: + return b + } + }() info.Files = nil err = filepath.Walk(root, func(path string, fi os.FileInfo, err error) error { if err != nil {