mirror of
https://github.com/9001/copyparty.git
synced 2025-12-27 07:54:13 -05:00
use vmaxb in the web-ui too;
also caches the volume usage to restore most of the performance lost in 511dc01615
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user