fix remove update
This commit is contained in:
parent
d892400ca7
commit
3a20946f62
@ -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():
|
||||
|
@ -149,12 +149,6 @@ class Command(metaclass=Singleton):
|
||||
"description": "当前版本",
|
||||
"category": "管理",
|
||||
"data": {}
|
||||
},
|
||||
"/update": {
|
||||
"func": SystemChain().update,
|
||||
"description": "更新系统",
|
||||
"category": "管理",
|
||||
"data": {}
|
||||
}
|
||||
}
|
||||
# 汇总插件命令
|
||||
|
@ -38,7 +38,6 @@ class MoviePilotUpdateNotify(_PluginBase):
|
||||
_enabled = False
|
||||
# 任务执行间隔
|
||||
_cron = None
|
||||
_update = False
|
||||
_notify = False
|
||||
|
||||
# 定时器
|
||||
@ -51,7 +50,6 @@ class MoviePilotUpdateNotify(_PluginBase):
|
||||
if config:
|
||||
self._enabled = config.get("enabled")
|
||||
self._cron = config.get("cron")
|
||||
self._update = config.get("update")
|
||||
self._notify = config.get("notify")
|
||||
|
||||
# 加载模块
|
||||
@ -100,11 +98,6 @@ class MoviePilotUpdateNotify(_PluginBase):
|
||||
f"\n"
|
||||
f"{update_time}")
|
||||
|
||||
# 自动更新
|
||||
if self._update:
|
||||
logger.info("开始执行自动更新…")
|
||||
SystemChain().update()
|
||||
|
||||
@staticmethod
|
||||
def __get_release_version():
|
||||
"""
|
||||
@ -146,7 +139,7 @@ class MoviePilotUpdateNotify(_PluginBase):
|
||||
'component': 'VCol',
|
||||
'props': {
|
||||
'cols': 12,
|
||||
'md': 4
|
||||
'md': 6
|
||||
},
|
||||
'content': [
|
||||
{
|
||||
@ -162,23 +155,7 @@ class MoviePilotUpdateNotify(_PluginBase):
|
||||
'component': 'VCol',
|
||||
'props': {
|
||||
'cols': 12,
|
||||
'md': 4
|
||||
},
|
||||
'content': [
|
||||
{
|
||||
'component': 'VSwitch',
|
||||
'props': {
|
||||
'model': 'update',
|
||||
'label': '自动更新',
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
'component': 'VCol',
|
||||
'props': {
|
||||
'cols': 12,
|
||||
'md': 4
|
||||
'md': 6
|
||||
},
|
||||
'content': [
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user