Skip to content

Commit

Permalink
Fixed #22681 -- Made TarArchive recognize leading directories properly.
Browse files Browse the repository at this point in the history
  • Loading branch information
phpdude authored and timgraham committed Jun 3, 2014
1 parent 61960dd commit 083d285
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion django/utils/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def extract(self, to_path):
# note: python<=2.5 doesn't seem to know about pax headers, filter them
members = [member for member in self._archive.getmembers()
if member.name != 'pax_global_header']
leading = self.has_leading_dir(members)
leading = self.has_leading_dir(x.name for x in members)
for member in members:
name = member.name
if leading:
Expand Down
Binary file added tests/utils_tests/archives/leadpath_foobar.tar
Binary file not shown.
Binary file added tests/utils_tests/archives/leadpath_foobar.tar.bz2
Binary file not shown.
Binary file added tests/utils_tests/archives/leadpath_foobar.tar.gz
Binary file not shown.
Binary file added tests/utils_tests/archives/leadpath_foobar.zip
Binary file not shown.
5 changes: 5 additions & 0 deletions tests/utils_tests/test_archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def setUp(self):
self.tmpdir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, self.tmpdir)
self.archive_path = os.path.join(TEST_DIR, self.archive)
self.archive_lead_path = os.path.join(TEST_DIR, "leadpath_%s" % self.archive)
# Always start off in TEST_DIR.
os.chdir(TEST_DIR)

Expand All @@ -42,6 +43,10 @@ def test_extract_function(self):
extract(self.archive_path, self.tmpdir)
self.check_files(self.tmpdir)

def test_extract_function_with_leadpath(self):
extract(self.archive_lead_path, self.tmpdir)
self.check_files(self.tmpdir)

def test_extract_function_no_to_path(self):
os.chdir(self.tmpdir)
extract(self.archive_path)
Expand Down

0 comments on commit 083d285

Please sign in to comment.