Skip to content

tarfile: Make it possible to extract nested tarfiles in memory #1032

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

woju
Copy link

@woju woju commented Jul 14, 2025

Make it possible to extract nested archives, which are used in e.g. Mender artifacts. See commit message for details and a (simplified) example.

FileSection.skip() (see below the diff) uses 2-argument readinto, so
attempting to recursively extract archives throws an error. This commit
adds optional second argument to fix this problem. After this commit, it
is possible to extract nested archives in roughly this fashion:

    with open(path, 'rb') as file:
        tar_outer = tarfile.TarFile(fileobj=file)
        for ti_outer in tar_outer:
            tar_inner = tarfile.TarFile(
                fileobj=tar_outer.extractfile(ti_outer))
            for ti_inner in tar_inner:
                ...

Nested archives are used in some embedded contexts, for example Mender
artifacts.

Signed-off-by: Wojciech Porczyk <wojciech.porczyk@connectpoint.pl>
@woju woju force-pushed the tarfile-nested branch from 927617c to f2217df Compare July 14, 2025 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy