clamp lastmod to y6325 (closes #1470);

fromtimestamp fails on year>9999
This commit is contained in:
ed 2026-05-25 11:08:19 +00:00
parent 926c6e814d
commit 27031f73be
3 changed files with 6 additions and 5 deletions

View file

@ -1,8 +1,8 @@
#!/usr/bin/env python3
from __future__ import print_function, unicode_literals
S_VERSION = "2.20"
S_BUILD_DT = "2026-04-22"
S_VERSION = "2.21"
S_BUILD_DT = "2026-05-25"
"""
u2c.py: upload to copyparty
@ -1311,7 +1311,8 @@ class Ctl(object):
if self.ar.jw:
print("%s %s" % (wark, vp))
else:
zd = datetime.datetime.fromtimestamp(max(0, file.lmod), UTC)
tsdt = datetime.datetime.fromtimestamp
zd = tsdt(max(0, min(2 << 36, file.lmod)), UTC)
dt = "%04d-%02d-%02d %02d:%02d:%02d" % (
zd.year,
zd.month,

View file

@ -7238,7 +7238,7 @@ class HttpCli(object):
margin = "-"
sz = inf.st_size
zd = datetime.fromtimestamp(max(0, linf.st_mtime), UTC)
zd = datetime.fromtimestamp(max(0, min(2 << 36, linf.st_mtime)), UTC)
dt = "%04d-%02d-%02d %02d:%02d:%02d" % (
zd.year,
zd.month,

View file

@ -3077,7 +3077,7 @@ class Up2k(object):
)
zi = cj["lmod"]
bad_mt = zi <= 0 or zi > 0xAAAAAAAA
bad_mt = zi <= 0 or zi > (2 << 36)
if bad_mt or vfs.flags.get("up_ts", "") == "fu":
# force upload time rather than last-modified
cj["lmod"] = int(time.time())