-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit 927617c
tarfile: Make it possible to extract nested tarfiles in memory
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>1 parent f95568d commit 927617c
1 file changed
+3
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | - | ||
44 | + | ||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | + | ||
50 | + | ||
49 | 51 | | |
50 | 52 | | |
51 | 53 | | |
| |||
0 commit comments