small perf optimizing. Only remove whiteout path if it needs to be included in the tar
@@ -161,18 +161,15 @@ 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 {
