mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 17:12:13 -06:00
only clean thumbs if there are thumbs to clean
This commit is contained in:
parent
062730c70c
commit
5c58fda46d
|
@ -559,14 +559,15 @@ class ThumbSrv(object):
|
||||||
def clean(self, histpath: str) -> int:
|
def clean(self, histpath: str) -> int:
|
||||||
ret = 0
|
ret = 0
|
||||||
for cat in ["th", "ac"]:
|
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
|
return ret
|
||||||
|
|
||||||
def _clean(self, histpath: str, cat: str, thumbpath: str) -> int:
|
def _clean(self, cat: str, thumbpath: str) -> int:
|
||||||
if not thumbpath:
|
|
||||||
thumbpath = os.path.join(histpath, cat)
|
|
||||||
|
|
||||||
# self.log("cln {}".format(thumbpath))
|
# self.log("cln {}".format(thumbpath))
|
||||||
exts = ["jpg", "webp"] if cat == "th" else ["opus", "caf"]
|
exts = ["jpg", "webp"] if cat == "th" else ["opus", "caf"]
|
||||||
maxage = getattr(self.args, cat + "_maxage")
|
maxage = getattr(self.args, cat + "_maxage")
|
||||||
|
@ -600,7 +601,7 @@ class ThumbSrv(object):
|
||||||
self.log("rm -rf [{}]".format(fp))
|
self.log("rm -rf [{}]".format(fp))
|
||||||
shutil.rmtree(fp, ignore_errors=True)
|
shutil.rmtree(fp, ignore_errors=True)
|
||||||
else:
|
else:
|
||||||
self._clean(histpath, cat, fp)
|
ndirs += self._clean(cat, fp)
|
||||||
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue