@staticmethod<EOL><INDENT>def tarfile_extract(fileobj, dest_path):<DEDENT>
<EOL>tar = tarfile.open(mode='<STR_LIT>', fileobj=fileobj,<EOL>bufsize=pipebuf.PIPE_BUF_BYTES)<EOL>dest_path = os.path.realpath(dest_path)<EOL>extracted_files = []<EOL>for member in tar:<EOL><INDENT>assert not member.name.startswith('<STR_LIT:/>')<EOL>relpath = os.path.join(dest_path, member.name)<EOL>if member.issym():<EOL><INDENT>target_path = os.path.join(dest_path, member.name)<EOL>try:<EOL><INDENT>os.symlink(member.linkname, target_path)<EOL><DEDENT>except OSError as e:<EOL><INDENT>if e.errno == errno.EEXIST:<EOL><INDENT>os.remove(target_path)<EOL>os.symlink(member.linkname, target_path)<EOL><DEDENT>else:<EOL><INDENT>raise<EOL><DEDENT><DEDENT>continue<EOL><DEDENT>if member.isreg() and member.size >= pipebuf.PIPE_BUF_BYTES:<EOL><INDENT>cat_extract(tar, member, relpath)<EOL><DEDENT>else:<EOL><INDENT>tar.extract(member, path=dest_path)<EOL><DEDENT>filename = os.path.realpath(relpath)<EOL>extracted_files.append(filename)<EOL>if len(extracted_files) > <NUM_LIT:1000>:<EOL><INDENT>_fsync_files(extracted_files)<EOL>del extracted_files[:]<EOL><DEDENT><DEDENT>tar.close()<EOL>_fsync_files(extracted_files)<EOL>
Extract a tarfile described by a file object to a specified path.

        Args:
            fileobj (file): File object wrapping the target tarfile.
            dest_path (str): Path to extract the contents of the tarfile to.