Issue #1735: TarFile.extractall() now correctly sets

directory permissions and times.

(will backport to 2.5)
This commit is contained in:
Lars Gustäbel 2008-01-04 14:00:33 +00:00
parent 0687561c94
commit 2ee1c760cc
3 changed files with 24 additions and 4 deletions

View file

@ -244,6 +244,23 @@ class MiscReadTest(ReadTest):
data = open(os.path.join(TEMPDIR, "ustar/symtype"), "rb").read()
self.assertEqual(md5sum(data), md5_regtype)
def test_extractall(self):
# Test if extractall() correctly restores directory permissions
# and times (see issue1735).
if sys.platform == "win32":
# Win32 has no support for utime() on directories or
# fine grained permissions.
return
tar = tarfile.open(tarname, encoding="iso8859-1")
directories = [t for t in tar if t.isdir()]
tar.extractall(TEMPDIR, directories)
for tarinfo in directories:
path = os.path.join(TEMPDIR, tarinfo.name)
self.assertEqual(tarinfo.mode & 0777, os.stat(path).st_mode & 0777)
self.assertEqual(tarinfo.mtime, os.path.getmtime(path))
tar.close()
class StreamReadTest(ReadTest):