From 98baf922d615a825c6c07a9cf350a30e6489f8eb Mon Sep 17 00:00:00 2001 From: jxxghp Date: Fri, 12 Apr 2024 21:38:53 +0800 Subject: [PATCH 1/6] fix resource exception --- app/helper/resource.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/helper/resource.py b/app/helper/resource.py index 732a8efe..072d3171 100644 --- a/app/helper/resource.py +++ b/app/helper/resource.py @@ -76,8 +76,10 @@ class ResourceHelper(metaclass=Singleton): # 下载文件信息列表 r = RequestUtils(proxies=settings.PROXY, headers=settings.GITHUB_HEADERS, timeout=30).get_res(self._files_api) - if not r or r.status_code != 200: + if r and not r.ok: return None, f"连接仓库失败:{r.status_code} - {r.reason}" + elif not r: + return None, "连接仓库失败" files_info = r.json() for item in files_info: save_path = need_updates.get(item.get("name")) From 6a8a946ec8ec2f446430d02c8122eca63a02e70e Mon Sep 17 00:00:00 2001 From: thsrite Date: Sat, 13 Apr 2024 17:05:12 +0800 Subject: [PATCH 2/6] =?UTF-8?q?fix=20PluginHelper().install=E5=B7=B2?= =?UTF-8?q?=E7=BB=8F=E7=BB=9F=E8=AE=A1=E5=AE=89=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/endpoints/plugin.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/api/endpoints/plugin.py b/app/api/endpoints/plugin.py index c1672932..7f57efec 100644 --- a/app/api/endpoints/plugin.py +++ b/app/api/endpoints/plugin.py @@ -97,8 +97,6 @@ def install(plugin_id: str, install_plugins.append(plugin_id) # 保存设置 SystemConfigOper().set(SystemConfigKey.UserInstalledPlugins, install_plugins) - # 统计 - PluginHelper().install_reg(plugin_id) # 加载插件到内存 PluginManager().reload_plugin(plugin_id) # 注册插件服务 From fc65cc361922348f1f94613f7c3cc81457b30099 Mon Sep 17 00:00:00 2001 From: thsrite Date: Sat, 13 Apr 2024 17:33:08 +0800 Subject: [PATCH 3/6] =?UTF-8?q?fix=20=E5=8D=95=E4=BE=8B=E5=8A=A0=E9=94=81?= =?UTF-8?q?=EF=BC=8C=E9=98=B2=E6=AD=A2init=E6=96=B9=E6=B3=95=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E8=BF=87=E9=95=BF=E5=AF=BC=E8=87=B4=E5=A4=9A=E6=AC=A1?= =?UTF-8?q?init?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/utils/singleton.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/utils/singleton.py b/app/utils/singleton.py index 908b2ffd..057531d6 100644 --- a/app/utils/singleton.py +++ b/app/utils/singleton.py @@ -1,4 +1,5 @@ import abc +import threading class Singleton(abc.ABCMeta, type): @@ -7,12 +8,14 @@ class Singleton(abc.ABCMeta, type): """ _instances: dict = {} + _lock = threading.Lock() def __call__(cls, *args, **kwargs): key = (cls, args, frozenset(kwargs.items())) - if key not in cls._instances: - cls._instances[key] = super().__call__(*args, **kwargs) - return cls._instances[key] + with cls._lock: + if key not in cls._instances: + cls._instances[key] = super().__call__(*args, **kwargs) + return cls._instances[key] class AbstractSingleton(abc.ABC, metaclass=Singleton): From 492533dcdbf5ee36b1a64c73575952e0609755a4 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Sat, 13 Apr 2024 18:38:29 +0800 Subject: [PATCH 4/6] rollback #1884 --- app/utils/singleton.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/utils/singleton.py b/app/utils/singleton.py index 057531d6..ece2355c 100644 --- a/app/utils/singleton.py +++ b/app/utils/singleton.py @@ -8,14 +8,12 @@ class Singleton(abc.ABCMeta, type): """ _instances: dict = {} - _lock = threading.Lock() def __call__(cls, *args, **kwargs): key = (cls, args, frozenset(kwargs.items())) - with cls._lock: - if key not in cls._instances: - cls._instances[key] = super().__call__(*args, **kwargs) - return cls._instances[key] + if key not in cls._instances: + cls._instances[key] = super().__call__(*args, **kwargs) + return cls._instances[key] class AbstractSingleton(abc.ABC, metaclass=Singleton): From fe07602a35476ca36583e1872a63db078faa9f14 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Sat, 13 Apr 2024 18:56:07 +0800 Subject: [PATCH 5/6] =?UTF-8?q?fix=20=E6=96=B0=E5=A2=9E=E7=AB=99=E7=82=B9?= =?UTF-8?q?=E5=8C=BA=E5=88=86=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/endpoints/site.py | 4 +++- app/utils/singleton.py | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/api/endpoints/site.py b/app/api/endpoints/site.py index c5623e77..052f7bcc 100644 --- a/app/api/endpoints/site.py +++ b/app/api/endpoints/site.py @@ -42,10 +42,12 @@ def add_site( """ if not site_in.url: return schemas.Response(success=False, message="站点地址不能为空") + if SitesHelper().auth_level < 2: + return schemas.Response(success=False, message="用户未通过认证,无法使用站点功能!") domain = StringUtils.get_url_domain(site_in.url) site_info = SitesHelper().get_indexer(domain) if not site_info: - return schemas.Response(success=False, message="该站点不支持或用户未通过认证") + return schemas.Response(success=False, message="该站点不支持,请检查站点域名是否正确") if Site.get_by_domain(db, domain): return schemas.Response(success=False, message=f"{domain} 站点己存在") # 保存站点信息 diff --git a/app/utils/singleton.py b/app/utils/singleton.py index ece2355c..505f5ba3 100644 --- a/app/utils/singleton.py +++ b/app/utils/singleton.py @@ -1,5 +1,4 @@ import abc -import threading class Singleton(abc.ABCMeta, type): @@ -19,4 +18,4 @@ class Singleton(abc.ABCMeta, type): class AbstractSingleton(abc.ABC, metaclass=Singleton): """ 抽像类单例模式 - """ \ No newline at end of file + """ From babad5a0983e315043dce8278350c32c15148795 Mon Sep 17 00:00:00 2001 From: thsrite Date: Sun, 14 Apr 2024 11:54:38 +0800 Subject: [PATCH 6/6] =?UTF-8?q?fix=20=E6=8F=92=E4=BB=B6=E5=A4=9A=E6=AC=A1?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/core/plugin.py | 2 -- app/main.py | 4 +++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/core/plugin.py b/app/core/plugin.py index cfba6487..b9560075 100644 --- a/app/core/plugin.py +++ b/app/core/plugin.py @@ -35,8 +35,6 @@ class PluginManager(metaclass=Singleton): self.siteshelper = SitesHelper() self.pluginhelper = PluginHelper() self.systemconfig = SystemConfigOper() - self.install_online_plugin() - self.init_config() def init_config(self): # 停止已有插件 diff --git a/app/main.py b/app/main.py index c95ac560..c4f543d4 100644 --- a/app/main.py +++ b/app/main.py @@ -195,8 +195,10 @@ def start_module(): ResourceHelper() # 加载模块 ModuleManager() + # 安装在线插件 + PluginManager().install_online_plugin() # 加载插件 - PluginManager() + PluginManager().start() # 启动定时服务 Scheduler() # 启动事件消费