Merge "Avoid creating temporary removal lists"
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
|
||||
import contextlib
|
||||
import copy
|
||||
import itertools
|
||||
import posixpath as pp
|
||||
|
||||
import six
|
||||
@@ -199,9 +200,8 @@ class FakeFilesystem(object):
|
||||
node = self._fetch_node(path, normalized=True)
|
||||
if node is self._root:
|
||||
raise ValueError("Can not delete '%s'" % self._root.item)
|
||||
removals = [path]
|
||||
removals.extend(child.metadata['path'] for child in node.bfs_iter())
|
||||
for path in removals:
|
||||
child_gen = (child.metadata['path'] for child in node.bfs_iter())
|
||||
for path in itertools.chain([path], child_gen):
|
||||
self._reverse_mapping.pop(path, None)
|
||||
node.disassociate()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user