diff --git a/pkg/snapshot/snapshot.go b/pkg/snapshot/snapshot.go index 2a84c50da..783d83083 100644 --- a/pkg/snapshot/snapshot.go +++ b/pkg/snapshot/snapshot.go @@ -135,7 +135,10 @@ func (s *Snapshotter) scanFullFilesystem() ([]string, []string, error) { timer := timing.Start("Walking filesystem") - foundPaths := make([]string, 0) + changedPaths := make([]string, 0) + + // Get a list of all the files that existed before this layer + existingPaths := s.l.getFlattenedPathsForWhiteOut() godirwalk.Walk(s.directory, &godirwalk.Options{ Callback: func(path string, ent *godirwalk.Dirent) error { @@ -150,8 +153,9 @@ func (s *Snapshotter) scanFullFilesystem() ([]string, []string, error) { if ok, err := s.l.CheckFileChange(path); err != nil { return err } else if ok { - foundPaths = append(foundPaths, path) + changedPaths = append(changedPaths, path) } + delete(existingPaths, path) return nil }, Unsorted: true, @@ -159,17 +163,13 @@ func (s *Snapshotter) scanFullFilesystem() ([]string, []string, error) { ) timing.DefaultRun.Stop(timer) timer = timing.Start("Resolving Paths") - // First handle whiteouts - // Get a list of all the files that existed before this layer - existingPaths := s.l.getFlattenedPathsForWhiteOut() filesToAdd := []string{} - resolvedFiles, err := filesystem.ResolvePaths(foundPaths, s.ignorelist) + resolvedFiles, err := filesystem.ResolvePaths(changedPaths, s.ignorelist) if err != nil { return nil, nil, err } for _, path := range resolvedFiles { - delete(existingPaths, path) if util.CheckIgnoreList(path) { logrus.Tracef("Not adding %s to layer, as it's whitelisted", path) continue