From 5e12abbb9b817dd456cf1e1ca8af5fe41c20aadf Mon Sep 17 00:00:00 2001 From: ed Date: Fri, 28 Feb 2025 17:48:14 +0000 Subject: [PATCH] ignore impossible lastmod on upload; closes #142 android-chrome bug https://issues.chromium.org/issues/393149335 sends last-modified time `-11644473600` for all uploads this has been fixed in chromium, but there might be similar bugs in other browsers, so add server-side and client-side detection for unreasonable lastmod times previously, if the js detected a similar situation, it would substitute the lastmod-time with the client's wallclock, but now the server's wallclock is always preferrred as fallback --- copyparty/up2k.py | 7 ++++++- copyparty/web/up2k.js | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/copyparty/up2k.py b/copyparty/up2k.py index f6f6fa20..be36f2ed 100644 --- a/copyparty/up2k.py +++ b/copyparty/up2k.py @@ -2954,9 +2954,14 @@ class Up2k(object): self.salt, cj["size"], cj["lmod"], cj["prel"], cj["name"] ) - if vfs.flags.get("up_ts", "") == "fu" or not cj["lmod"]: + zi = cj["lmod"] + bad_mt = zi <= 0 or zi > 0xAAAAAAAA + if bad_mt or vfs.flags.get("up_ts", "") == "fu": # force upload time rather than last-modified cj["lmod"] = int(time.time()) + if zi and bad_mt: + t = "ignoring impossible last-modified time from client: %s" + self.log(t % (zi,), 6) alts: list[tuple[int, int, dict[str, Any], "sqlite3.Cursor", str, str]] = [] for ptop, cur in vols: diff --git a/copyparty/web/up2k.js b/copyparty/web/up2k.js index 7e50162f..a0fa380b 100644 --- a/copyparty/web/up2k.js +++ b/copyparty/web/up2k.js @@ -1409,7 +1409,7 @@ function up2k_init(subtle) { name = good_files[a][1], fdir = evpath, now = Date.now(), - lmod = uc.u2ts ? (fobj.lastModified || now) : 0, + lmod = (uc.u2ts && fobj.lastModified) || 0, ofs = name.lastIndexOf('/') + 1; if (ofs) {