- Add a shared AUFS utility lib and change both changes and streamlayerformat to use it

- Add UI for selecting whether to pull the tag, the repo, or the squashed tag
This commit is contained in:
Joseph Schorr 2014-09-18 15:56:59 -04:00
parent 43555af63d
commit 05bb710830
8 changed files with 197 additions and 79 deletions

View file

@ -1,16 +1,10 @@
import marisa_trie
import os
import tarfile
AUFS_METADATA = u'.wh..wh.'
AUFS_WHITEOUT = u'.wh.'
AUFS_WHITEOUT_PREFIX_LENGTH = len(AUFS_WHITEOUT)
from aufs import is_aufs_metadata, get_deleted_prefix
ALLOWED_TYPES = {tarfile.REGTYPE, tarfile.AREGTYPE}
def files_and_dirs_from_tar(source_stream, removed_prefix_collector):
try:
tar_stream = tarfile.open(mode='r|*', fileobj=source_stream)
@ -20,22 +14,19 @@ def files_and_dirs_from_tar(source_stream, removed_prefix_collector):
for tar_info in tar_stream:
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
# Skip metadata.
if is_aufs_metadata(absolute):
continue
elif filename.startswith(AUFS_WHITEOUT):
removed_filename = filename[AUFS_WHITEOUT_PREFIX_LENGTH:]
removed_prefix = os.path.join('/', dirname, removed_filename)
removed_prefix_collector.add(removed_prefix)
# Add prefixes of removed paths to the collector.
deleted_prefix = get_deleted_prefix(absolute)
if deleted_prefix is not None:
deleted_prefix.add(deleted_prefix)
continue
elif tar_info.type in ALLOWED_TYPES:
# Otherwise, yield the path if it is in the allowed types.
if tar_info.type in ALLOWED_TYPES:
yield '/' + absolute