From 95d9e693c63ac2b931e89635a4cf6991a60ff04f Mon Sep 17 00:00:00 2001 From: ed Date: Mon, 22 Apr 2024 18:55:13 +0000 Subject: [PATCH] d2d should disable search/unpost even if db exists --- copyparty/httpcli.py | 4 ++-- copyparty/metrics.py | 2 +- copyparty/u2idx.py | 10 +++++++--- tests/test_dots.py | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index 227ec2ea..205a8849 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -3867,7 +3867,7 @@ class HttpCli(object): 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) if not cur: continue @@ -4093,7 +4093,7 @@ class HttpCli(object): if is_dir and (e2t or e2d): idx = self.conn.get_u2idx() if idx and hasattr(idx, "p_end"): - icur = idx.get_cur(dbv.realpath) + icur = idx.get_cur(dbv) th_fmt = self.uparam.get("th") if self.can_read or (self.can_get and vn.flags.get("dk")): diff --git a/copyparty/metrics.py b/copyparty/metrics.py index 3af8be9d..bf7a4151 100644 --- a/copyparty/metrics.py +++ b/copyparty/metrics.py @@ -179,7 +179,7 @@ class Metrics(object): tnbytes = 0 tnfiles = 0 for vpath, vol in allvols: - cur = idx.get_cur(vol.realpath) + cur = idx.get_cur(vol) if not cur: continue diff --git a/copyparty/u2idx.py b/copyparty/u2idx.py index 90736094..c9ffe141 100644 --- a/copyparty/u2idx.py +++ b/copyparty/u2idx.py @@ -81,14 +81,18 @@ class U2idx(object): except: raise Pebkac(500, min_ex()) - def get_cur(self, ptop: str) -> Optional["sqlite3.Cursor"]: + def get_cur(self, vn: VFS) -> Optional["sqlite3.Cursor"]: if not HAVE_SQLITE3: return None - cur = self.cur.get(ptop) + cur = self.cur.get(vn.realpath) if cur: return cur + if "e2d" not in vn.flags: + return None + + ptop = vn.realpath histpath = self.asrv.vfs.histtab.get(ptop) if not histpath: self.log("no histpath for [{}]".format(ptop)) @@ -317,7 +321,7 @@ class U2idx(object): ptop = vol.realpath flags = vol.flags - cur = self.get_cur(ptop) + cur = self.get_cur(vol) if not cur: continue diff --git a/tests/test_dots.py b/tests/test_dots.py index 946a3773..577d52d6 100644 --- a/tests/test_dots.py +++ b/tests/test_dots.py @@ -80,7 +80,7 @@ class TestHttpCli(unittest.TestCase): x = " ".join(sorted([x["rp"] for x in x[0]])) self.assertEqual(x, ".f0 .t/.f2 .t/f2 a/da/f4 a/f3 f0 t/.f1 t/f1") - self.args = Cfg(v=vcfg, a=["u1:u1", "u2:u2"], dotsrch=False) + self.args = Cfg(v=vcfg, a=["u1:u1", "u2:u2"], dotsrch=False, e2d=True) self.asrv = AuthSrv(self.args, self.log) u2idx = U2idx(self)