Make sure to keep the timestamp when untaring

closes #3201
This commit is contained in:
Xavier Fernandez 2015-12-18 18:49:05 +01:00
parent 41cf790d7a
commit 227572f757
2 changed files with 7 additions and 5 deletions

View File

@ -562,12 +562,10 @@ def untar_file(filename, location):
)
continue
ensure_dir(os.path.dirname(path))
destfp = open(path, 'wb')
try:
with open(path, 'wb') as destfp:
shutil.copyfileobj(fp, destfp)
finally:
destfp.close()
fp.close()
# Update the timestamp (useful for cython compiled files)
tar.utime(member, path)
# member have any execute permissions for user/group/world?
if member.mode & 0o111:
# make dest file have execute for user/group/world

View File

@ -327,6 +327,10 @@ class TestUnpackArchives(object):
test_file = data.packages.join("test_tar.tgz")
untar_file(test_file, self.tempdir)
self.confirm_files()
# Check the timestamp of an extracted file
file_txt_path = os.path.join(self.tempdir, 'file.txt')
mtime = time.gmtime(os.stat(file_txt_path).st_mtime)
assert mtime[0:6] == (2013, 8, 16, 5, 13, 37), mtime
def test_unpack_zip(self, data):
"""