spectrograms are never cropped; share thumbcache

This commit is contained in:
ed 2023-10-15 11:42:57 +00:00
parent edbafd94c2
commit db668ba491
5 changed files with 12 additions and 6 deletions

View file

@ -12,7 +12,7 @@ import threading
import time import time
from datetime import datetime from datetime import datetime
from .__init__ import ANYWIN, E, TYPE_CHECKING, WINDOWS from .__init__ import ANYWIN, TYPE_CHECKING, WINDOWS, E
from .bos import bos from .bos import bos
from .cfg import flagdescs, permdescs, vf_bmap, vf_cmap, vf_vmap from .cfg import flagdescs, permdescs, vf_bmap, vf_cmap, vf_vmap
from .pwhash import PWHash from .pwhash import PWHash

View file

@ -170,7 +170,7 @@ class HttpSrv(object):
if self.args.log_thrs: if self.args.log_thrs:
start_log_thrs(self.log, self.args.log_thrs, nid) start_log_thrs(self.log, self.args.log_thrs, nid)
self.th_cfg: dict[str, Any] = {} self.th_cfg: dict[str, set[str]] = {}
Daemon(self.post_init, "hsrv-init2") Daemon(self.post_init, "hsrv-init2")
def post_init(self) -> None: def post_init(self) -> None:

View file

@ -162,6 +162,7 @@ class SMB(object):
if "connData" in cl: if "connData" in cl:
return cl["connData"]["partygoer"] return cl["connData"]["partygoer"]
cf = cf.f_back cf = cf.f_back
raise Exception()
except: except:
warning( warning(
"nyoron... %s <<-- %s <<-- %s <<-- %s", "nyoron... %s <<-- %s <<-- %s <<-- %s",

View file

@ -31,7 +31,7 @@ class ThumbCli(object):
if not c: if not c:
raise Exception() raise Exception()
except: except:
c = {k: {} for k in ["thumbable", "pil", "vips", "ffi", "ffv", "ffa"]} c = {k: set() for k in ["thumbable", "pil", "vips", "ffi", "ffv", "ffa"]}
self.thumbable = c["thumbable"] self.thumbable = c["thumbable"]
self.fmt_pil = c["pil"] self.fmt_pil = c["pil"]
@ -94,7 +94,7 @@ class ThumbCli(object):
self.log("no histpath for [{}]".format(ptop)) self.log("no histpath for [{}]".format(ptop))
return None return None
tpath = thumb_path(histpath, rem, mtime, fmt) tpath = thumb_path(histpath, rem, mtime, fmt, self.fmt_ffa)
tpaths = [tpath] tpaths = [tpath]
if fmt == "w": if fmt == "w":
# also check for jpg (maybe webp is unavailable) # also check for jpg (maybe webp is unavailable)

View file

@ -79,7 +79,7 @@ except:
HAVE_VIPS = False HAVE_VIPS = False
def thumb_path(histpath: str, rem: str, mtime: float, fmt: str) -> str: def thumb_path(histpath: str, rem: str, mtime: float, fmt: str, ffa: set[str]) -> str:
# base16 = 16 = 256 # base16 = 16 = 256
# b64-lc = 38 = 1444 # b64-lc = 38 = 1444
# base64 = 64 = 4096 # base64 = 64 = 4096
@ -87,6 +87,11 @@ def thumb_path(histpath: str, rem: str, mtime: float, fmt: str) -> str:
if not rd: if not rd:
rd = "\ntop" rd = "\ntop"
# spectrograms are never cropped; strip fullsize flag
ext = rem.split(".")[-1].lower()
if ext in ffa and fmt in ("wf", "jf"):
fmt = fmt[:1]
rd += "\n" + fmt rd += "\n" + fmt
h = hashlib.sha512(afsenc(rd)).digest() h = hashlib.sha512(afsenc(rd)).digest()
b64 = base64.urlsafe_b64encode(h).decode("ascii")[:24] b64 = base64.urlsafe_b64encode(h).decode("ascii")[:24]
@ -195,7 +200,7 @@ class ThumbSrv(object):
self.log("no histpath for [{}]".format(ptop)) self.log("no histpath for [{}]".format(ptop))
return None return None
tpath = thumb_path(histpath, rem, mtime, fmt) tpath = thumb_path(histpath, rem, mtime, fmt, self.fmt_ffa)
abspath = os.path.join(ptop, rem) abspath = os.path.join(ptop, rem)
cond = threading.Condition(self.mutex) cond = threading.Condition(self.mutex)
do_conv = False do_conv = False