- 修复v1.3.5版本的问题
This commit is contained in:
parent
f59609131c
commit
5fc7a7dd8a
@ -24,12 +24,11 @@ class DownloadHistoryOper(DbOper):
|
||||
"""
|
||||
return DownloadHistory.get_by_hash(self._db, download_hash)
|
||||
|
||||
def add(self, **kwargs) -> DownloadHistory:
|
||||
def add(self, **kwargs):
|
||||
"""
|
||||
新增下载历史
|
||||
"""
|
||||
downloadhistory = DownloadHistory(**kwargs)
|
||||
return downloadhistory.create(self._db)
|
||||
DownloadHistory(**kwargs).create(self._db)
|
||||
|
||||
def add_files(self, file_items: List[dict]):
|
||||
"""
|
||||
|
@ -12,9 +12,8 @@ class Base:
|
||||
__name__: str
|
||||
|
||||
@db_update
|
||||
def create(self, db: Session) -> Self:
|
||||
def create(self, db: Session):
|
||||
db.add(self)
|
||||
return self
|
||||
|
||||
@classmethod
|
||||
@db_query
|
||||
|
@ -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
|
||||
@ -25,10 +25,8 @@ class PluginDataOper(DbOper):
|
||||
plugin.update(self._db, {
|
||||
"value": value
|
||||
})
|
||||
return plugin
|
||||
else:
|
||||
plugin = PluginData(plugin_id=plugin_id, key=key, value=value)
|
||||
return plugin.create(self._db)
|
||||
PluginData(plugin_id=plugin_id, key=key, value=value).create(self._db)
|
||||
|
||||
def get_data(self, plugin_id: str, key: str) -> Any:
|
||||
"""
|
||||
|
@ -43,14 +43,14 @@ class TransferHistoryOper(DbOper):
|
||||
"""
|
||||
return TransferHistory.list_by_hash(self._db, download_hash)
|
||||
|
||||
def add(self, **kwargs) -> TransferHistory:
|
||||
def add(self, **kwargs):
|
||||
"""
|
||||
新增转移历史
|
||||
"""
|
||||
kwargs.update({
|
||||
"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]:
|
||||
"""
|
||||
@ -103,7 +103,8 @@ class TransferHistoryOper(DbOper):
|
||||
kwargs.update({
|
||||
"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):
|
||||
"""
|
||||
|
@ -5,7 +5,6 @@ from typing import Any, List, Dict, Tuple
|
||||
from app.chain import ChainBase
|
||||
from app.core.config import settings
|
||||
from app.core.event import EventManager
|
||||
from app.db.models import Base
|
||||
from app.db.plugindata_oper import PluginDataOper
|
||||
from app.db.systemconfig_oper import SystemConfigOper
|
||||
from app.helper.message import MessageHelper
|
||||
@ -141,7 +140,7 @@ class _PluginBase(metaclass=ABCMeta):
|
||||
data_path.mkdir(parents=True)
|
||||
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
|
||||
@ -150,7 +149,7 @@ class _PluginBase(metaclass=ABCMeta):
|
||||
"""
|
||||
if not plugin_id:
|
||||
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:
|
||||
"""
|
||||
|
Loading…
x
Reference in New Issue
Block a user