th: no keepalive-pokes if th-clean 0

This commit is contained in:
ed 2026-07-09 22:16:11 +00:00
parent 8884606138
commit e15f292766
4 changed files with 14 additions and 11 deletions

View file

@ -1802,7 +1802,7 @@ def add_thumbnail(ap):
ap2.add_argument("--th-ff-jpg", action="store_true", help="force jpg output for video thumbs (avoids issues on some FFmpeg builds)")
ap2.add_argument("--th-ff-swr", action="store_true", help="use swresample instead of soxr for audio thumbs (faster, lower accuracy, avoids issues on some FFmpeg builds)")
ap2.add_argument("--th-vips-jxl", metavar="N", type=int, default=1, help="when to allow generating jxl thumbnails with libvips; 0=never, 1=musl-mallocng, 2=always")
ap2.add_argument("--th-poke", metavar="SEC", type=int, default=300, help="activity labeling cooldown -- avoids doing keepalive pokes (updating the mtime) on thumbnail folders more often than \033[33mSEC\033[0m seconds")
ap2.add_argument("--th-poke", metavar="SEC", type=int, default=300, help="activity labeling cooldown -- avoids doing keepalive pokes (updating the mtime) on thumbnail folders more often than \033[33mSEC\033[0m seconds; 0=no-keepalive")
ap2.add_argument("--th-clean", metavar="SEC", type=int, default=43200, help="cleanup interval; 0=disabled")
ap2.add_argument("--th-maxage", metavar="SEC", type=int, default=604800, help="max folder age -- folders which haven't been poked for longer than \033[33m--th-poke\033[0m seconds will get deleted every \033[33m--th-clean\033[0m seconds")
ap2.add_argument("--th-pregen", metavar="F,F", type=u, default="", help="pregenerate thumbnails on startup; \033[33mF,F\033[0m is comma-separated list of formats; example: [\033[32mj,jf,w,w3,wf,wf3,x,xf\033[0m] NOTE: remember to set \033[33m--th-maxage 123456789\033[0m (volflag=th_pregen)")

View file

@ -476,6 +476,8 @@ class SvcHub(object):
}
args.th_poke = min(args.th_poke, args.th_maxage, args.ac_maxage)
if not args.th_clean:
args.th_poke = 0
zms = ""
if not args.https_only:

View file

@ -31,7 +31,7 @@ class ThumbCli(object):
self.asrv = hsrv.asrv
# cache on both sides for less broker spam
self.cooldown = Cooldown(self.args.th_poke)
self.cooldown = Cooldown(self.args.th_poke) if self.args.th_poke else None
self.thumbable = c["thumbable"]
self.fmt_pil = c["pil"]
@ -149,14 +149,15 @@ class ThumbCli(object):
pass
if ret:
tdir = os.path.dirname(tpath)
if self.cooldown.poke(tdir):
self.broker.say("thumbsrv.poke", tdir)
if self.cooldown:
tdir = os.path.dirname(tpath)
if self.cooldown.poke(tdir):
self.broker.say("thumbsrv.poke", tdir)
if want_opus:
# audio files expire individually
if self.cooldown.poke(tpath):
self.broker.say("thumbsrv.poke", tpath)
if want_opus:
# audio files expire individually
if self.cooldown.poke(tpath):
self.broker.say("thumbsrv.poke", tpath)
return ret

View file

@ -273,7 +273,7 @@ class ThumbSrv(object):
self.log = self._log
self.nextlog = 0
self.poke_cd = Cooldown(self.args.th_poke)
self.poke_cd = Cooldown(self.args.th_poke) if self.args.th_poke else None
self.mutex = threading.Lock()
self.busy: dict[str, list[threading.Condition]] = {}
@ -1419,7 +1419,7 @@ class ThumbSrv(object):
return ret
def poke(self, tdir: str) -> None:
if not self.poke_cd.poke(tdir):
if not self.poke_cd or not self.poke_cd.poke(tdir):
return
ts = int(time.time())