From a5a2b03fd2d366ee9955607a3cbf2d1f57a2a1a3 Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Wed, 29 Oct 2014 18:09:15 +0000 Subject: Allow invert_paths to skip the top level directory We're going to be passing it "$CHROOT/" as a writable directory by default, so it needs to be able to tell that it means to leave everything writable. --- morphlib/fsutils.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'morphlib/fsutils.py') diff --git a/morphlib/fsutils.py b/morphlib/fsutils.py index 751f73f6..6d651171 100644 --- a/morphlib/fsutils.py +++ b/morphlib/fsutils.py @@ -104,6 +104,11 @@ def invert_paths(tree_walker, paths): for dirpath, dirnames, filenames in tree_walker: + if any(p == dirpath for p in paths): # pragma: no cover + # Dir is an exact match for a path + # don't recurse any further + # Don't yield it, since we don't return listed paths + continue dn_copy = list(dirnames) for subdir in dn_copy: subdirpath = os.path.join(dirpath, subdir) -- cgit v1.2.1