Skip to content

Commit

Permalink
handle case
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuarli committed Oct 4, 2024
1 parent 1c0af0d commit 4097f6b
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion devenv/lib/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,21 @@ def strip_n(
end += next_at + 1

stripped_prefix = member.path[:end]
breakpoint()

if end == 0:
if strip_n == 1:
# A common case where the first member is the directory
# to be stripped. In a python TarInfo object it won't have
# a trailing slash.
stripped_prefix = member.path[:]
end = len(stripped_prefix)
elif strip_n > 1:
raise ValueError(
f"""unexpected archive structure:
trying to strip {strip_n} leading components but {member.path} isn't that deep
"""
)

for member in members:
if not member.path.startswith(stripped_prefix):
Expand Down

0 comments on commit 4097f6b

Please sign in to comment.