fix bug
This commit is contained in:
parent
c46b1dd116
commit
faa6d7dadd
@ -39,6 +39,12 @@ class DownloadHistoryOper(DbOper):
|
|||||||
downloadfile = DownloadFiles(**file_item)
|
downloadfile = DownloadFiles(**file_item)
|
||||||
downloadfile.create(self._db)
|
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]:
|
def get_files_by_hash(self, download_hash: str, state: int = None) -> List[DownloadFiles]:
|
||||||
"""
|
"""
|
||||||
按Hash查询下载文件记录
|
按Hash查询下载文件记录
|
||||||
|
@ -211,7 +211,7 @@ class MessageForward(_PluginBase):
|
|||||||
expires_in = wechat_config['expires_in']
|
expires_in = wechat_config['expires_in']
|
||||||
access_token = wechat_config['access_token']
|
access_token = wechat_config['access_token']
|
||||||
# 判断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
|
# 已过期,重新获取token
|
||||||
access_token, expires_in, access_token_time = self.__get_access_token(corpid=corpid,
|
access_token, expires_in, access_token_time = self.__get_access_token(corpid=corpid,
|
||||||
appsecret=appsecret)
|
appsecret=appsecret)
|
||||||
|
@ -44,6 +44,7 @@ class SyncDownloadFiles(_PluginBase):
|
|||||||
tr = None
|
tr = None
|
||||||
_onlyonce = False
|
_onlyonce = False
|
||||||
_history = False
|
_history = False
|
||||||
|
_clear = False
|
||||||
_downloaders = []
|
_downloaders = []
|
||||||
_dirs = None
|
_dirs = None
|
||||||
downloadhis = None
|
downloadhis = None
|
||||||
@ -56,21 +57,33 @@ class SyncDownloadFiles(_PluginBase):
|
|||||||
# 停止现有任务
|
# 停止现有任务
|
||||||
self.stop_service()
|
self.stop_service()
|
||||||
|
|
||||||
if config:
|
|
||||||
self._enabled = config.get('enabled')
|
|
||||||
self._time = config.get('time') or 6
|
|
||||||
self._history = config.get('history')
|
|
||||||
self._onlyonce = config.get("onlyonce")
|
|
||||||
self._downloaders = config.get('downloaders') or []
|
|
||||||
self._dirs = config.get("dirs") or ""
|
|
||||||
|
|
||||||
if self._onlyonce:
|
|
||||||
# 执行一次
|
|
||||||
self.qb = Qbittorrent()
|
self.qb = Qbittorrent()
|
||||||
self.tr = Transmission()
|
self.tr = Transmission()
|
||||||
self.downloadhis = DownloadHistoryOper(self.db)
|
self.downloadhis = DownloadHistoryOper(self.db)
|
||||||
self.transferhis = TransferHistoryOper(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:
|
||||||
|
# 执行一次
|
||||||
# 关闭onlyonce
|
# 关闭onlyonce
|
||||||
self._onlyonce = False
|
self._onlyonce = False
|
||||||
self.__update_config()
|
self.__update_config()
|
||||||
@ -224,6 +237,7 @@ class SyncDownloadFiles(_PluginBase):
|
|||||||
"enabled": self._enabled,
|
"enabled": self._enabled,
|
||||||
"time": self._time,
|
"time": self._time,
|
||||||
"history": self._history,
|
"history": self._history,
|
||||||
|
"clear": self._clear,
|
||||||
"onlyonce": self._onlyonce,
|
"onlyonce": self._onlyonce,
|
||||||
"downloaders": self._downloaders,
|
"downloaders": self._downloaders,
|
||||||
"dirs": self._dirs
|
"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,
|
"enabled": False,
|
||||||
"onlyonce": False,
|
"onlyonce": False,
|
||||||
"history": False,
|
"history": False,
|
||||||
|
"clear": False,
|
||||||
"time": 6,
|
"time": 6,
|
||||||
"dirs": "",
|
"dirs": "",
|
||||||
"downloaders": []
|
"downloaders": []
|
||||||
|
Loading…
x
Reference in New Issue
Block a user