Perform recursion after handling all blocks of current file

This way file access isn't interleaved and all dependencies of one file are
reported before moving to the next.
This commit is contained in:
Sybren A. Stüvel 2018-02-28 17:02:19 +01:00
parent 55302004ee
commit 2af8d94cb9

View File

@ -34,12 +34,19 @@ class _Tracer:
log.info('Tracing %s', bfilepath)
self.seen_files.add(bfilepath)
recurse_into = []
with blendfile.BlendFile(bfilepath) as bfile:
for block in asset_holding_blocks(bfile):
yield from block_walkers.from_block(block)
if recursive and block.code == b'LI':
yield from self._recurse_deps(block)
recurse_into.append(block)
# Deal with recursion after we've handled all dependencies of the
# current file, so that file access isn't interleaved and all deps
# of one file are reported before moving to the next.
for block in recurse_into:
yield from self._recurse_deps(block)
def _recurse_deps(self, lib_block: blendfile.BlendFileBlock) \
-> typing.Iterator[result.BlockUsage]: