mirror of
https://github.com/9001/copyparty.git
synced 2025-12-27 10:15:16 -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.vbmax = 0 # volume bytes max
|
||||||
self.vnmax = 0 # volume max num files
|
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.smin = 0 # filesize min
|
||||||
self.smax = 0 # filesize max
|
self.smax = 0 # filesize max
|
||||||
|
|
||||||
|
|||||||
@@ -1834,13 +1834,18 @@ class HttpCli(object):
|
|||||||
bfree, btot, _ = get_df(vn.realpath, False)
|
bfree, btot, _ = get_df(vn.realpath, False)
|
||||||
if btot:
|
if btot:
|
||||||
if "vmaxb" in vn.flags:
|
if "vmaxb" in vn.flags:
|
||||||
try:
|
if bfree == vn.lim.c_vb_r:
|
||||||
zi, _ = self.conn.hsrv.broker.ask(
|
bfree = min(bfree, max(0, vn.lim.vbmax - vn.lim.c_vb_v))
|
||||||
"up2k.get_volsizes", [vn.realpath]
|
else:
|
||||||
).get()[0]
|
try:
|
||||||
bfree = min(bfree, max(0, vn.lim.vbmax - zi))
|
zi, _ = self.conn.hsrv.broker.ask(
|
||||||
except:
|
"up2k.get_volsizes", [vn.realpath]
|
||||||
pass
|
).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 = {
|
df = {
|
||||||
"quota-available-bytes": str(bfree),
|
"quota-available-bytes": str(bfree),
|
||||||
"quota-used-bytes": str(btot - bfree),
|
"quota-used-bytes": str(btot - bfree),
|
||||||
@@ -6738,6 +6743,19 @@ class HttpCli(object):
|
|||||||
):
|
):
|
||||||
free, total, zs = get_df(abspath, False)
|
free, total, zs = get_df(abspath, False)
|
||||||
if total:
|
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)
|
h1 = humansize(free or 0)
|
||||||
h2 = humansize(total)
|
h2 = humansize(total)
|
||||||
srv_info.append("{} free of {}".format(h1, h2))
|
srv_info.append("{} free of {}".format(h1, h2))
|
||||||
|
|||||||
Reference in New Issue
Block a user