This commit is contained in:
thsrite 2023-09-08 11:20:25 +08:00
parent c46b1dd116
commit faa6d7dadd
3 changed files with 43 additions and 6 deletions

View File

@ -39,6 +39,12 @@ class DownloadHistoryOper(DbOper):
downloadfile = DownloadFiles(**file_item)
downloadfile.create(self._db)
def truncate_files(self):
"""
清空下载历史文件记录
"""
DownloadFiles.truncate(self._db)
def get_files_by_hash(self, download_hash: str, state: int = None) -> List[DownloadFiles]:
"""
按Hash查询下载文件记录

View File

@ -211,7 +211,7 @@ class MessageForward(_PluginBase):
expires_in = wechat_config['expires_in']
access_token = wechat_config['access_token']
# 判断token是否过期
if (datetime.now() - access_token_time).seconds < expires_in:
if (datetime.now() - datetime.strptime(access_token_time, "%Y-%m-%d %H:%M:%S")).seconds < expires_in:
# 已过期重新获取token
access_token, expires_in, access_token_time = self.__get_access_token(corpid=corpid,
appsecret=appsecret)

View File

@ -44,6 +44,7 @@ class SyncDownloadFiles(_PluginBase):
tr = None
_onlyonce = False
_history = False
_clear = False
_downloaders = []
_dirs = None
downloadhis = None
@ -56,21 +57,33 @@ class SyncDownloadFiles(_PluginBase):
# 停止现有任务
self.stop_service()
self.qb = Qbittorrent()
self.tr = Transmission()
self.downloadhis = DownloadHistoryOper(self.db)
self.transferhis = TransferHistoryOper(self.db)
if config:
self._enabled = config.get('enabled')
self._time = config.get('time') or 6
self._history = config.get('history')
self._clear = config.get('clear')
self._onlyonce = config.get("onlyonce")
self._downloaders = config.get('downloaders') or []
self._dirs = config.get("dirs") or ""
if self._clear:
# 清理下载器文件记录
self.downloadhis.truncate_files()
# 清理下载器最后处理记录
for downloader in self._downloaders:
# 获取最后同步时间
self.del_data(f"last_sync_time_{downloader}")
# 关闭clear
self._clear = False
self.__update_config()
if self._onlyonce:
# 执行一次
self.qb = Qbittorrent()
self.tr = Transmission()
self.downloadhis = DownloadHistoryOper(self.db)
self.transferhis = TransferHistoryOper(self.db)
# 关闭onlyonce
self._onlyonce = False
self.__update_config()
@ -224,6 +237,7 @@ class SyncDownloadFiles(_PluginBase):
"enabled": self._enabled,
"time": self._time,
"history": self._history,
"clear": self._clear,
"onlyonce": self._onlyonce,
"downloaders": self._downloaders,
"dirs": self._dirs
@ -434,6 +448,22 @@ class SyncDownloadFiles(_PluginBase):
}
]
},
{
'component': 'VCol',
'props': {
'cols': 12,
'md': 4
},
'content': [
{
'component': 'VSwitch',
'props': {
'model': 'clear',
'label': '清理数据',
}
}
]
},
]
},
{
@ -526,6 +556,7 @@ class SyncDownloadFiles(_PluginBase):
"enabled": False,
"onlyonce": False,
"history": False,
"clear": False,
"time": 6,
"dirs": "",
"downloaders": []