From 4dd5d4e1b7c8b7fcb1ac94b46de7423b467f399d Mon Sep 17 00:00:00 2001 From: ed Date: Tue, 8 Jun 2021 18:35:55 +0200 Subject: [PATCH] when rootless, blank instead of block rootdir --- copyparty/authsrv.py | 4 ++-- copyparty/up2k.py | 11 ++++++++--- tests/test_vfs.py | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/copyparty/authsrv.py b/copyparty/authsrv.py index 892b573c..25aa905b 100644 --- a/copyparty/authsrv.py +++ b/copyparty/authsrv.py @@ -22,7 +22,7 @@ class VFS(object): self.uadm = uadm # users who are regular admins self.flags = flags # config switches self.nodes = {} # child nodes - self.all_vols = {vpath: self} # flattened recursive + self.all_vols = {vpath: self} if realpath else {} # flattened recursive def __repr__(self): return "VFS({})".format( @@ -430,7 +430,7 @@ class AuthSrv(object): vfs = VFS(os.path.abspath("."), "", ["*"], ["*"]) elif "" not in mount: # there's volumes but no root; make root inaccessible - vfs = VFS(os.path.abspath("."), "") + vfs = VFS(None, "") vfs.flags["d2d"] = True maxdepth = 0 diff --git a/copyparty/up2k.py b/copyparty/up2k.py index 06087b2d..42ba849f 100644 --- a/copyparty/up2k.py +++ b/copyparty/up2k.py @@ -186,12 +186,14 @@ class Up2k(object): self.log("cannot access " + vol.realpath, c=1) continue + if scan_vols and vol.vpath not in scan_vols: + continue + if not self.register_vpath(vol.realpath, vol.flags): # self.log("db not enabled for {}".format(m, vol.realpath)) continue - if vol.vpath in scan_vols or not scan_vols: - live_vols.append(vol) + live_vols.append(vol) if vol.vpath not in self.volstate: self.volstate[vol.vpath] = "OFFLINE (pending initialization)" @@ -288,7 +290,10 @@ class Up2k(object): def register_vpath(self, ptop, flags): db_path = os.path.join(ptop, ".hist", "up2k.db") if ptop in self.registry: - return [self.cur[ptop], db_path] + try: + return [self.cur[ptop], db_path] + except: + return None _, flags = self._expr_idx_filter(flags) diff --git a/tests/test_vfs.py b/tests/test_vfs.py index 4714b722..23fe5919 100644 --- a/tests/test_vfs.py +++ b/tests/test_vfs.py @@ -251,7 +251,7 @@ class TestVFS(unittest.TestCase): n = au.vfs # root was not defined, so PWD with no access to anyone self.assertEqual(n.vpath, "") - self.assertEqual(n.realpath, td) + self.assertEqual(n.realpath, None) self.assertEqual(n.uread, []) self.assertEqual(n.uwrite, []) self.assertEqual(len(n.nodes), 1)