From e0845b2363f58dd70d1ba5f57dff23760ccc42b4 Mon Sep 17 00:00:00 2001 From: ed Date: Tue, 23 Dec 2025 22:11:38 +0000 Subject: [PATCH] use vmaxb in the web-ui too; also caches the volume usage to restore most of the performance lost in 511dc016152ddeb0caba1a745a20b1e7d8413014 --- copyparty/authsrv.py | 3 +++ copyparty/httpcli.py | 32 +++++++++++++++++++++++++------- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/copyparty/authsrv.py b/copyparty/authsrv.py index 2b096334..06507344 100644 --- a/copyparty/authsrv.py +++ b/copyparty/authsrv.py @@ -167,6 +167,9 @@ class Lim(object): self.vbmax = 0 # volume bytes max self.vnmax = 0 # volume max num files + self.c_vb_v = 0 # cache: volume bytes used (value) + self.c_vb_r = 0 # cache: volume bytes used (ref) + self.smin = 0 # filesize min self.smax = 0 # filesize max diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index 43efd755..8f85cbbd 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -1834,13 +1834,18 @@ class HttpCli(object): bfree, btot, _ = get_df(vn.realpath, False) if btot: if "vmaxb" in vn.flags: - try: - zi, _ = self.conn.hsrv.broker.ask( - "up2k.get_volsizes", [vn.realpath] - ).get()[0] - bfree = min(bfree, max(0, vn.lim.vbmax - zi)) - except: - pass + if bfree == vn.lim.c_vb_r: + bfree = min(bfree, max(0, vn.lim.vbmax - vn.lim.c_vb_v)) + else: + try: + zi, _ = self.conn.hsrv.broker.ask( + "up2k.get_volsizes", [vn.realpath] + ).get()[0] + vn.lim.c_vb_v = zi + vn.lim.c_vb_r = bfree + bfree = min(bfree, max(0, vn.lim.vbmax - zi)) + except: + pass df = { "quota-available-bytes": str(bfree), "quota-used-bytes": str(btot - bfree), @@ -6738,6 +6743,19 @@ class HttpCli(object): ): free, total, zs = get_df(abspath, False) if total: + if "vmaxb" in vn.flags: + if free == vn.lim.c_vb_r: + free = min(free, max(0, vn.lim.vbmax - vn.lim.c_vb_v)) + else: + try: + zi, _ = self.conn.hsrv.broker.ask( + "up2k.get_volsizes", [vn.realpath] + ).get()[0] + vn.lim.c_vb_v = zi + vn.lim.c_vb_r = free + free = min(free, max(0, vn.lim.vbmax - zi)) + except: + pass h1 = humansize(free or 0) h2 = humansize(total) srv_info.append("{} free of {}".format(h1, h2))