You've already forked favicon-api-v3
25.09.06
This commit is contained in:
@@ -16,7 +16,7 @@ from bs4 import SoupStrainer
|
||||
from fastapi import Request, BackgroundTasks
|
||||
from fastapi.responses import Response
|
||||
|
||||
from favicon_app.models import Favicon
|
||||
from favicon_app.models import Favicon, favicon
|
||||
from favicon_app.utils import header
|
||||
from favicon_app.utils.file_util import FileUtil
|
||||
from favicon_app.utils.filetype import helpers, filetype
|
||||
@@ -368,6 +368,9 @@ class FaviconService:
|
||||
sync: Optional[str] = None
|
||||
) -> dict[str, str] | Response:
|
||||
"""处理获取图标的请求"""
|
||||
|
||||
logger.info(f"队列大小:{self.icon_queue.qsize()} | {self.total_queue.qsize()}")
|
||||
|
||||
with self._lock:
|
||||
self.url_count += 1
|
||||
|
||||
@@ -383,6 +386,15 @@ class FaviconService:
|
||||
logger.warning(f"无效的URL: {url}")
|
||||
return self.get_default(self.time_of_7_days)
|
||||
|
||||
# 检查内存缓存中的失败URL
|
||||
with self._lock:
|
||||
if entity.domain in favicon.failed_urls:
|
||||
_expire_time = favicon.failed_urls[entity.domain]
|
||||
if int(time.time()) <= _expire_time:
|
||||
return self.get_default(self.time_of_7_days)
|
||||
else:
|
||||
del favicon.failed_urls[entity.domain]
|
||||
|
||||
# 检查缓存
|
||||
_cached, cached_icon = self._get_cache_icon(entity.domain_md5, refresh=refresh in ['true', '1', 'True'])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user