From 67db51810bca1b10281c4ada0e7340805bd4abd6 Mon Sep 17 00:00:00 2001 From: Tejal Desai Date: Wed, 18 Mar 2020 00:43:55 -0700 Subject: [PATCH] small perf optimizing. Only remove whiteout path if it needs to be included in the tar --- pkg/util/fs_util.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/pkg/util/fs_util.go b/pkg/util/fs_util.go index 8f09b5b7e..a231c7e83 100644 --- a/pkg/util/fs_util.go +++ b/pkg/util/fs_util.go @@ -161,18 +161,15 @@ func GetFSFromLayers(root string, layers []v1.Layer, opts ...FSOpt) ([]string, e dir := filepath.Dir(path) if strings.HasPrefix(base, ".wh.") { - logrus.Debugf("Whiting out %s", path) - - name := strings.TrimPrefix(base, ".wh.") - if err := os.RemoveAll(filepath.Join(dir, name)); err != nil { - return nil, errors.Wrapf(err, "removing whiteout %s", hdr.Name) - } - if !cfg.includeWhiteout { logrus.Debug("not including whiteout files") continue } - + logrus.Debugf("Whiting out %s", path) + name := strings.TrimPrefix(base, ".wh.") + if err := os.RemoveAll(filepath.Join(dir, name)); err != nil { + return nil, errors.Wrapf(err, "removing whiteout %s", hdr.Name) + } } if err := cfg.extractFunc(root, hdr, tr); err != nil {