From 8f5f8a3cdac135dcb4d7a1c2147effd9a4e74765 Mon Sep 17 00:00:00 2001 From: ed Date: Fri, 14 Apr 2023 18:55:19 +0200 Subject: [PATCH] expand userhomes everywhere: * -c * -lo * --hist * hist volflag * --ssl-log --- copyparty/__main__.py | 4 ++-- copyparty/authsrv.py | 6 +++++- copyparty/svchub.py | 19 ++++++++++++++++--- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/copyparty/__main__.py b/copyparty/__main__.py index ba38c271..15effeda 100755 --- a/copyparty/__main__.py +++ b/copyparty/__main__.py @@ -900,8 +900,8 @@ def add_db_general(ap, hcores): ap2.add_argument("-e2vu", action="store_true", help="on hash mismatch: update the database with the new hash") ap2.add_argument("-e2vp", action="store_true", help="on hash mismatch: panic and quit copyparty") ap2.add_argument("--hist", metavar="PATH", type=u, help="where to store volume data (db, thumbs) (volflag=hist)") - ap2.add_argument("--no-hash", metavar="PTN", type=u, help="regex: disable hashing of matching paths during e2ds folder scans (volflag=nohash)") - ap2.add_argument("--no-idx", metavar="PTN", type=u, help="regex: disable indexing of matching paths during e2ds folder scans (volflag=noidx)") + ap2.add_argument("--no-hash", metavar="PTN", type=u, help="regex: disable hashing of matching absolute-filesystem-paths during e2ds folder scans (volflag=nohash)") + ap2.add_argument("--no-idx", metavar="PTN", type=u, help="regex: disable indexing of matching absolute-filesystem-paths during e2ds folder scans (volflag=noidx)") ap2.add_argument("--no-dhash", action="store_true", help="disable rescan acceleration; do full database integrity check -- makes the db ~5%% smaller and bootup/rescans 3~10x slower") ap2.add_argument("--re-dhash", action="store_true", help="rebuild the cache if it gets out of sync (for example crash on startup during metadata scanning)") ap2.add_argument("--no-forget", action="store_true", help="never forget indexed files, even when deleted from disk -- makes it impossible to ever upload the same file twice (volflag=noforget)") diff --git a/copyparty/authsrv.py b/copyparty/authsrv.py index bb030ddc..e2cdc66c 100644 --- a/copyparty/authsrv.py +++ b/copyparty/authsrv.py @@ -356,7 +356,8 @@ class VFS(object): flags = {k: v for k, v in self.flags.items()} hist = flags.get("hist") if hist and hist != "-": - flags["hist"] = "{}/{}".format(hist.rstrip("/"), name) + zs = "{}/{}".format(hist.rstrip("/"), name) + flags["hist"] = os.path.expanduser(zs) if zs.startswith("~") else zs return flags @@ -1101,6 +1102,9 @@ class AuthSrv(object): if vflag == "-": pass elif vflag: + if vflag.startswith("~"): + vflag = os.path.expanduser(vflag) + vol.histpath = uncyg(vflag) if WINDOWS else vflag elif self.args.hist: for nch in range(len(hid)): diff --git a/copyparty/svchub.py b/copyparty/svchub.py index 0557707b..a0a7d9ec 100644 --- a/copyparty/svchub.py +++ b/copyparty/svchub.py @@ -128,6 +128,9 @@ class SvcHub(object): args.no_robots = True args.force_js = True + if not self._process_config(): + raise Exception("bad config") + self.log = self._log_disabled if args.q else self._log_enabled if args.lo: self._setup_logfile(printed) @@ -177,9 +180,6 @@ class SvcHub(object): self.log("root", "max clients: {}".format(self.args.nc)) - if not self._process_config(): - raise Exception("bad config") - self.tcpsrv = TcpSrv(self) self.up2k = Up2k(self) @@ -350,6 +350,19 @@ class SvcHub(object): al.th_covers = set(al.th_covers.split(",")) + for k in "c".split(" "): + vl = getattr(al, k) + if not vl: + continue + + vl = [os.path.expanduser(x) if x.startswith("~") else x for x in vl] + setattr(al, k, vl) + + for k in "lo hist ssl_log".split(" "): + vs = getattr(al, k) + if vs and vs.startswith("~"): + setattr(al, k, os.path.expanduser(vs)) + return True def _setlimits(self) -> None: