From b2e233403d6a21c1f184595c779f7c7af2c04190 Mon Sep 17 00:00:00 2001 From: ed Date: Sat, 27 Jan 2024 18:49:25 +0000 Subject: [PATCH] u2c: apply exclude-filter to deletion too if a file gets synced and you later add an exclude-filter for it, delete the file from the server as if it doesn't exist locally --- bin/u2c.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/bin/u2c.py b/bin/u2c.py index 8de25850..4054532b 100755 --- a/bin/u2c.py +++ b/bin/u2c.py @@ -1,8 +1,8 @@ #!/usr/bin/env python3 from __future__ import print_function, unicode_literals -S_VERSION = "1.13" -S_BUILD_DT = "2024-01-24" +S_VERSION = "1.14" +S_BUILD_DT = "2024-01-27" """ u2c.py: upload to copyparty @@ -877,6 +877,8 @@ class Ctl(object): self.st_hash = [file, ofs] def hasher(self): + ptn = re.compile(self.ar.x.encode("utf-8"), re.I) if self.ar.x else None + sep = "{0}".format(os.sep).encode("ascii") prd = None ls = {} for top, rel, inf in self.filegen: @@ -909,7 +911,12 @@ class Ctl(object): if self.ar.drd: dp = os.path.join(top, rd) lnodes = set(os.listdir(dp)) - bnames = [x for x in ls if x not in lnodes] + if ptn: + zs = dp.replace(sep, b"/").rstrip(b"/") + b"/" + zls = [zs + x for x in lnodes] + zls = [x for x in zls if not ptn.match(x)] + lnodes = [x.split(b"/")[-1] for x in zls] + bnames = [x for x in ls if x not in lnodes and x != b".hist"] vpath = self.ar.url.split("://")[-1].split("/", 1)[-1] names = [x.decode("utf-8", "replace") for x in bnames] locs = [vpath + srd + "/" + x for x in names]