From a7ca2e7881463080512976750d4c7f514745447d 2020-06-02 23:39:03 From: Matthias Bussonnier Date: 2020-06-02 23:39:03 Subject: [PATCH] Backport PR #12358: Fix retaring process for twine. --- diff --git a/tools/retar.py b/tools/retar.py index dbdca0e..9b5e73c 100644 --- a/tools/retar.py +++ b/tools/retar.py @@ -47,10 +47,10 @@ for i, m in enumerate(old): m2.type = m.type m2.linkname = m.linkname if m.isdir(): + new.addfile(m2) + else: data = old.extractfile(m) new.addfile(m2, data) - else: - new.addfile(m2) new.close() old.close() @@ -58,3 +58,7 @@ buf.seek(0) with open(sys.argv[1], "wb") as f: with gzip.GzipFile('', "wb", fileobj=f, mtime=timestamp) as gzf: gzf.write(buf.read()) + +# checks the archive is valid. +archive = tarfile.open(sys.argv[1]) +names = archive.getnames()