Only return filepath.SkipDir for directories

From the docs on filepath.SkipDir:

> If the function returns SkipDir when invoked on a non-directory file, Walk skips the remaining files in the containing directory

This was causing the bug in #457. Since the file `/etc/hosts` was in the whitelist, when filepath.SkipDir was called the entire etc directory was skipped.

This change only returns filepath.SkipDir on directories.
This commit is contained in:
Priya Wadhwa
2018-11-19 15:56:11 -05:00
parent 0c294138b8
commit 2a359f547c
2 changed files with 16 additions and 2 deletions
+5 -2
View File
@@ -147,8 +147,11 @@ func (s *Snapshotter) TakeSnapshotFS() (string, error) {
return err
}
if util.IsInWhitelist(path) {
logrus.Infof("Skipping paths under %s, as it is a whitelisted directory", path)
return filepath.SkipDir
if util.IsDestDir(path) {
logrus.Infof("Skipping paths under %s, as it is a whitelisted directory", path)
return filepath.SkipDir
}
return nil
}
memFs[path] = info