fix unpost when there is no rootfs;

the volflags of `/` were used to determine if e2d was enabled,
which is wrong in two ways:

* if there is no `/` volume, it would be globally disabled

* if `/` has e2d, but another volume doesn't, it would
   erroneously think unpost was available, which is not an
   issue unless that volume used to have e2d enabled AND
   there is stale data matching the client's IP

3f05b665 (v1.11.0) had an incomplete fix for the stale-data part of
the above, which also introduced the other issue
This commit is contained in:
ed 2024-03-18 06:15:32 +01:00
parent 51d31588e6
commit 0287c7baa5

View file

@ -3605,8 +3605,6 @@ class HttpCli(object):
return ret return ret
def tx_ups(self) -> bool: def tx_ups(self) -> bool:
have_unpost = self.args.unpost and "e2d" in self.vn.flags
idx = self.conn.get_u2idx() idx = self.conn.get_u2idx()
if not idx or not hasattr(idx, "p_end"): if not idx or not hasattr(idx, "p_end"):
raise Pebkac(500, "sqlite3 is not available on the server; cannot unpost") raise Pebkac(500, "sqlite3 is not available on the server; cannot unpost")
@ -3630,8 +3628,14 @@ class HttpCli(object):
) )
uret = x.get() uret = x.get()
allvols = self.asrv.vfs.all_vols if have_unpost else {} if not self.args.unpost:
for vol in allvols.values(): allvols = []
else:
allvols = list(self.asrv.vfs.all_vols.values())
allvols = [x for x in allvols if "e2d" in x.flags]
for vol in allvols:
cur = idx.get_cur(vol.realpath) cur = idx.get_cur(vol.realpath)
if not cur: if not cur:
continue continue
@ -3683,7 +3687,7 @@ class HttpCli(object):
for v in ret: for v in ret:
v["vp"] = self.args.SR + v["vp"] v["vp"] = self.args.SR + v["vp"]
if not have_unpost: if not allvols:
ret = [{"kinshi": 1}] ret = [{"kinshi": 1}]
jtxt = '{"u":%s,"c":%s}' % (uret, json.dumps(ret, indent=0)) jtxt = '{"u":%s,"c":%s}' % (uret, json.dumps(ret, indent=0))