Fix bugs and clean up data in the way diffs are generated.
This commit is contained in:
parent
6bebfcc3a1
commit
4679b0dfcc
2 changed files with 16 additions and 9 deletions
|
@ -8,26 +8,31 @@ AUFS_METADATA = u'.wh..wh.'
|
|||
AUFS_WHITEOUT = u'.wh.'
|
||||
AUFS_WHITEOUT_PREFIX_LENGTH = len(AUFS_WHITEOUT)
|
||||
|
||||
ALLOWED_TYPES = {tarfile.REGTYPE, tarfile.AREGTYPE}
|
||||
|
||||
|
||||
def files_and_dirs_from_tar(source_stream, removed_prefix_collector):
|
||||
tar_stream = tarfile.open(mode='r|*', fileobj=source_stream)
|
||||
|
||||
for tar_info in tar_stream:
|
||||
absolute = os.path.relpath(unicode(tar_info.name), './')
|
||||
absolute = os.path.relpath(tar_info.name.decode('utf-8'), './')
|
||||
dirname = os.path.dirname(absolute)
|
||||
filename = os.path.basename(absolute)
|
||||
|
||||
# Skip directories and metadata
|
||||
if (filename.startswith(AUFS_METADATA) or
|
||||
absolute.startswith(AUFS_METADATA)):
|
||||
# Skip
|
||||
continue
|
||||
|
||||
elif filename.startswith(AUFS_WHITEOUT):
|
||||
filename = filename[AUFS_WHITEOUT_PREFIX_LENGTH:]
|
||||
removed_prefix_collector.add(absolute)
|
||||
removed_filename = filename[AUFS_WHITEOUT_PREFIX_LENGTH:]
|
||||
removed_prefix = os.path.join('/', dirname, removed_filename)
|
||||
removed_prefix_collector.add(removed_prefix)
|
||||
continue
|
||||
|
||||
else:
|
||||
yield "/" + absolute
|
||||
elif tar_info.type in ALLOWED_TYPES:
|
||||
yield '/' + absolute
|
||||
|
||||
|
||||
def __compute_removed(base_trie, removed_prefixes):
|
||||
|
|
Reference in a new issue