From 5c58fda46d55e9378f6d282895df272610b5e85a Mon Sep 17 00:00:00 2001 From: ed Date: Fri, 8 Jul 2022 21:13:10 +0200 Subject: [PATCH] only clean thumbs if there are thumbs to clean --- copyparty/th_srv.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/copyparty/th_srv.py b/copyparty/th_srv.py index 2a9e5f02..8ea48d05 100644 --- a/copyparty/th_srv.py +++ b/copyparty/th_srv.py @@ -559,14 +559,15 @@ class ThumbSrv(object): def clean(self, histpath: str) -> int: ret = 0 for cat in ["th", "ac"]: - ret += self._clean(histpath, cat, "") + top = os.path.join(histpath, cat) + if not bos.path.isdir(top): + continue + + ret += self._clean(cat, top) return ret - def _clean(self, histpath: str, cat: str, thumbpath: str) -> int: - if not thumbpath: - thumbpath = os.path.join(histpath, cat) - + def _clean(self, cat: str, thumbpath: str) -> int: # self.log("cln {}".format(thumbpath)) exts = ["jpg", "webp"] if cat == "th" else ["opus", "caf"] maxage = getattr(self.args, cat + "_maxage") @@ -600,7 +601,7 @@ class ThumbSrv(object): self.log("rm -rf [{}]".format(fp)) shutil.rmtree(fp, ignore_errors=True) else: - self._clean(histpath, cat, fp) + ndirs += self._clean(cat, fp) continue