- 修复v1.3.5版本的问题

This commit is contained in:
jxxghp 2023-10-20 08:07:38 +08:00
parent f59609131c
commit 5fc7a7dd8a
5 changed files with 11 additions and 15 deletions

View File

@ -24,12 +24,11 @@ class DownloadHistoryOper(DbOper):
""" """
return DownloadHistory.get_by_hash(self._db, download_hash) return DownloadHistory.get_by_hash(self._db, download_hash)
def add(self, **kwargs) -> DownloadHistory: def add(self, **kwargs):
""" """
新增下载历史 新增下载历史
""" """
downloadhistory = DownloadHistory(**kwargs) DownloadHistory(**kwargs).create(self._db)
return downloadhistory.create(self._db)
def add_files(self, file_items: List[dict]): def add_files(self, file_items: List[dict]):
""" """

View File

@ -12,9 +12,8 @@ class Base:
__name__: str __name__: str
@db_update @db_update
def create(self, db: Session) -> Self: def create(self, db: Session):
db.add(self) db.add(self)
return self
@classmethod @classmethod
@db_query @db_query

View File

@ -11,7 +11,7 @@ class PluginDataOper(DbOper):
插件数据管理 插件数据管理
""" """
def save(self, plugin_id: str, key: str, value: Any) -> PluginData: def save(self, plugin_id: str, key: str, value: Any):
""" """
保存插件数据 保存插件数据
:param plugin_id: 插件id :param plugin_id: 插件id
@ -25,10 +25,8 @@ class PluginDataOper(DbOper):
plugin.update(self._db, { plugin.update(self._db, {
"value": value "value": value
}) })
return plugin
else: else:
plugin = PluginData(plugin_id=plugin_id, key=key, value=value) PluginData(plugin_id=plugin_id, key=key, value=value).create(self._db)
return plugin.create(self._db)
def get_data(self, plugin_id: str, key: str) -> Any: def get_data(self, plugin_id: str, key: str) -> Any:
""" """

View File

@ -43,14 +43,14 @@ class TransferHistoryOper(DbOper):
""" """
return TransferHistory.list_by_hash(self._db, download_hash) return TransferHistory.list_by_hash(self._db, download_hash)
def add(self, **kwargs) -> TransferHistory: def add(self, **kwargs):
""" """
新增转移历史 新增转移历史
""" """
kwargs.update({ kwargs.update({
"date": time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) "date": time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
}) })
return TransferHistory(**kwargs).create(self._db) TransferHistory(**kwargs).create(self._db)
def statistic(self, days: int = 7) -> List[Any]: def statistic(self, days: int = 7) -> List[Any]:
""" """
@ -103,7 +103,8 @@ class TransferHistoryOper(DbOper):
kwargs.update({ kwargs.update({
"date": time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) "date": time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
}) })
return TransferHistory(**kwargs).create(self._db) TransferHistory(**kwargs).create(self._db)
return TransferHistory.get_by_src(self._db, kwargs.get("src"))
def update_download_hash(self, historyid, download_hash): def update_download_hash(self, historyid, download_hash):
""" """

View File

@ -5,7 +5,6 @@ from typing import Any, List, Dict, Tuple
from app.chain import ChainBase from app.chain import ChainBase
from app.core.config import settings from app.core.config import settings
from app.core.event import EventManager from app.core.event import EventManager
from app.db.models import Base
from app.db.plugindata_oper import PluginDataOper from app.db.plugindata_oper import PluginDataOper
from app.db.systemconfig_oper import SystemConfigOper from app.db.systemconfig_oper import SystemConfigOper
from app.helper.message import MessageHelper from app.helper.message import MessageHelper
@ -141,7 +140,7 @@ class _PluginBase(metaclass=ABCMeta):
data_path.mkdir(parents=True) data_path.mkdir(parents=True)
return data_path return data_path
def save_data(self, key: str, value: Any, plugin_id: str = None) -> Base: def save_data(self, key: str, value: Any, plugin_id: str = None):
""" """
保存插件数据 保存插件数据
:param key: 数据key :param key: 数据key
@ -150,7 +149,7 @@ class _PluginBase(metaclass=ABCMeta):
""" """
if not plugin_id: if not plugin_id:
plugin_id = self.__class__.__name__ plugin_id = self.__class__.__name__
return self.plugindata.save(plugin_id, key, value) self.plugindata.save(plugin_id, key, value)
def get_data(self, key: str, plugin_id: str = None) -> Any: def get_data(self, key: str, plugin_id: str = None) -> Any:
""" """