diff --git a/pkg/util/fs_util.go b/pkg/util/fs_util.go index 230d87669..af553f8c9 100644 --- a/pkg/util/fs_util.go +++ b/pkg/util/fs_util.go @@ -161,15 +161,18 @@ func GetFSFromLayers(root string, layers []v1.Layer, opts ...FSOpt) ([]string, e dir := filepath.Dir(path) if strings.HasPrefix(base, ".wh.") { - 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 !cfg.includeWhiteout { + logrus.Debug("not including whiteout files") + continue + } + } if err := cfg.extractFunc(root, hdr, tr); err != nil {