fix(public): 图标缓存优先返回真实 favicon,字母 SVG 仅作兜底
_resolve_icon 的本地缓存命中顺序改为先查 .ico/.png/.jpg/.gif 再查 .svg, 避免已生成的字母头像(.svg)遮盖后续补入的真实 favicon 缓存文件。
This commit is contained in:
@@ -343,13 +343,13 @@ def _resolve_icon(domain: str, letter: str):
|
|||||||
safe = _safe_name(domain)
|
safe = _safe_name(domain)
|
||||||
d = _icon_dir()
|
d = _icon_dir()
|
||||||
# 1) 命中本地缓存(任意已知扩展名)
|
# 1) 命中本地缓存(任意已知扩展名)
|
||||||
for ext in ('.svg', '.ico', '.png', '.jpg', '.jpeg', '.gif'):
|
for ext in ('.ico', '.png', '.jpg', '.jpeg', '.gif', '.svg'):
|
||||||
p = os.path.join(d, safe + ext)
|
p = os.path.join(d, safe + ext)
|
||||||
if os.path.isfile(p):
|
if os.path.isfile(p):
|
||||||
return p, _ICON_EXT_MIME.get(ext, 'application/octet-stream')
|
return p, _ICON_EXT_MIME.get(ext, 'application/octet-stream')
|
||||||
# 2) 加锁后再次检查(避免并发重复拉取)
|
# 2) 加锁后再次检查(避免并发重复拉取)
|
||||||
with _lock_for(safe):
|
with _lock_for(safe):
|
||||||
for ext in ('.svg', '.ico', '.png', '.jpg', '.jpeg', '.gif'):
|
for ext in ('.ico', '.png', '.jpg', '.jpeg', '.gif', '.svg'):
|
||||||
p = os.path.join(d, safe + ext)
|
p = os.path.join(d, safe + ext)
|
||||||
if os.path.isfile(p):
|
if os.path.isfile(p):
|
||||||
return p, _ICON_EXT_MIME.get(ext, 'application/octet-stream')
|
return p, _ICON_EXT_MIME.get(ext, 'application/octet-stream')
|
||||||
|
|||||||
Reference in New Issue
Block a user