better whiteout logic

This commit is contained in:
Tejal Desai 2020-06-06 10:50:24 -07:00
parent cbf4452fe9
commit b9d25dd5db
1 changed files with 7 additions and 7 deletions

View File

@ -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