changeset 5788:89882824b375

avoid strange exception in zipfile.py for pre-1980 timestamps
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Wed, 03 Aug 2011 00:07:16 +0200
parents 00704da830ea
children e1e79fab9cca 1e5d9851f5c5
files MoinMoin/action/PackagePages.py
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/PackagePages.py	Tue Aug 02 23:52:32 2011 +0200
+++ b/MoinMoin/action/PackagePages.py	Wed Aug 03 00:07:16 2011 +0200
@@ -201,6 +201,11 @@
             script.append(packLine(["AddRevision", str(cnt), page.page_name, userid, "Created by the PackagePages action."]))
 
             timestamp = wikiutil.version2timestamp(page.mtime_usecs())
+            
+            # avoid getting strange exceptions from zipfile in case of pre-1980 timestamps
+            nineteeneighty = (10 * 365 + 3) * 24 * 3600 # 1970 + 10y + 3d
+            timestamp = max(nineteeneighty, timestamp) # zip can not store timestamps before 1980
+
             zi = zipfile.ZipInfo(filename=str(cnt), date_time=datetime.fromtimestamp(timestamp).timetuple()[:6])
             zi.compress_type = COMPRESSION_LEVEL
             zf.writestr(zi, page.get_raw_body().encode("utf-8"))