fix remove update
This commit is contained in:
@ -1,5 +1,4 @@
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
from typing import Union
|
||||
|
||||
@ -18,7 +17,6 @@ class SystemChain(ChainBase, metaclass=Singleton):
|
||||
"""
|
||||
|
||||
_restart_file = "__system_restart__"
|
||||
_update_file = "__system_update__"
|
||||
|
||||
def remote_clear_cache(self, channel: MessageChannel, userid: Union[int, str]):
|
||||
"""
|
||||
@ -42,29 +40,6 @@ class SystemChain(ChainBase, metaclass=Singleton):
|
||||
}, self._restart_file)
|
||||
SystemUtils.restart()
|
||||
|
||||
def update(self, channel: MessageChannel = None, userid: Union[int, str] = None):
|
||||
"""
|
||||
重启系统
|
||||
"""
|
||||
if not SystemUtils.is_docker():
|
||||
logger.error("非Docker版本不支持自动更新!")
|
||||
return
|
||||
|
||||
if channel and userid:
|
||||
self.post_message(Notification(channel=channel,
|
||||
title="系统正在更新,请耐心等候!", userid=userid))
|
||||
# 保存重启信息
|
||||
self.save_cache({
|
||||
"channel": channel.value,
|
||||
"userid": userid
|
||||
}, self._update_file)
|
||||
|
||||
# 更新系统
|
||||
if not settings.MOVIEPILOT_AUTO_UPDATE:
|
||||
os.system("cd / && bash /usr/local/bin/mp_update")
|
||||
# 重启系统
|
||||
SystemUtils.restart()
|
||||
|
||||
def version(self, channel: MessageChannel, userid: Union[int, str]):
|
||||
"""
|
||||
查看当前版本、远程版本
|
||||
@ -84,12 +59,9 @@ class SystemChain(ChainBase, metaclass=Singleton):
|
||||
如通过交互命令重启,
|
||||
重启完发送msg
|
||||
"""
|
||||
cache_file, action, channel, userid = None, None, None, None
|
||||
# 重启消息
|
||||
restart_channel = self.load_cache(self._restart_file)
|
||||
if restart_channel:
|
||||
cache_file = self._restart_file
|
||||
action = "重启"
|
||||
# 发送重启完成msg
|
||||
if not isinstance(restart_channel, dict):
|
||||
restart_channel = json.loads(restart_channel)
|
||||
@ -98,21 +70,6 @@ class SystemChain(ChainBase, metaclass=Singleton):
|
||||
channel.value == restart_channel.get('channel')), None)
|
||||
userid = restart_channel.get('userid')
|
||||
|
||||
# 更新消息
|
||||
update_channel = self.load_cache(self._update_file)
|
||||
if update_channel:
|
||||
cache_file = self._update_file
|
||||
action = "更新"
|
||||
# 发送重启完成msg
|
||||
if not isinstance(update_channel, dict):
|
||||
update_channel = json.loads(update_channel)
|
||||
channel = next(
|
||||
(channel for channel in MessageChannel.__members__.values() if
|
||||
channel.value == update_channel.get('channel')), None)
|
||||
userid = update_channel.get('userid')
|
||||
|
||||
# 发送消息
|
||||
if channel and userid:
|
||||
# 版本号
|
||||
release_version = self.__get_release_version()
|
||||
local_version = self.get_local_version()
|
||||
@ -121,9 +78,9 @@ class SystemChain(ChainBase, metaclass=Singleton):
|
||||
else:
|
||||
title = f"当前版本:{local_version},远程版本:{release_version}"
|
||||
self.post_message(Notification(channel=channel,
|
||||
title=f"系统已{action}完成!{title}",
|
||||
title=f"系统已重启完成!{title}",
|
||||
userid=userid))
|
||||
self.remove_cache(cache_file)
|
||||
self.remove_cache(self._restart_file)
|
||||
|
||||
@staticmethod
|
||||
def __get_release_version():
|
||||
|
Reference in New Issue
Block a user