Kaydet (Commit) a60011ca authored tarafından Joffrey F's avatar Joffrey F

Add workaround for bpo-32713

Signed-off-by: 's avatarJoffrey F <joffrey@docker.com>
üst 91bc75cc
...@@ -107,6 +107,10 @@ def create_archive(root, files=None, fileobj=None, gzip=False): ...@@ -107,6 +107,10 @@ def create_archive(root, files=None, fileobj=None, gzip=False):
# ignore it and proceed. # ignore it and proceed.
continue continue
# Workaround https://bugs.python.org/issue32713
if i.mtime < 0 or i.mtime > 8**11 - 1:
i.mtime = int(i.mtime)
if constants.IS_WINDOWS_PLATFORM: if constants.IS_WINDOWS_PLATFORM:
# Windows doesn't keep track of the execute bit, so we make files # Windows doesn't keep track of the execute bit, so we make files
# and directories executable by default. # and directories executable by default.
......
...@@ -995,6 +995,18 @@ class TarTest(unittest.TestCase): ...@@ -995,6 +995,18 @@ class TarTest(unittest.TestCase):
tar_data = tarfile.open(fileobj=archive) tar_data = tarfile.open(fileobj=archive)
assert sorted(tar_data.getnames()) == ['bar', 'foo'] assert sorted(tar_data.getnames()) == ['bar', 'foo']
def tar_test_negative_mtime_bug(self):
base = tempfile.mkdtemp()
filename = os.path.join(base, 'th.txt')
self.addCleanup(shutil.rmtree, base)
with open(filename, 'w') as f:
f.write('Invisible Full Moon')
os.utime(filename, (12345, -3600.0))
with tar(base) as archive:
tar_data = tarfile.open(fileobj=archive)
assert tar_data.getnames() == ['th.txt']
assert tar_data.getmember('th.txt').mtime == -3600
class ShouldCheckDirectoryTest(unittest.TestCase): class ShouldCheckDirectoryTest(unittest.TestCase):
exclude_patterns = [ exclude_patterns = [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment