-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
feat: 添加自动更新功能(支持备份与回滚) #8697
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Dr1985
wants to merge
4
commits into
AstrBotDevs:master
Choose a base branch
from
Dr1985:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+232
−0
Open
feat: 添加自动更新功能(支持备份与回滚) #8697
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,9 @@ | |
| from astrbot.api import logger, sp | ||
| from astrbot.core import LogBroker, LogManager | ||
| from astrbot.core.astrbot_config_mgr import AstrBotConfigManager | ||
| from astrbot.core.auto_update import AutoUpdateManager | ||
| from astrbot.core.backup.exporter import AstrBotExporter | ||
| from astrbot.core.backup.importer import AstrBotImporter | ||
| from astrbot.core.config.default import VERSION | ||
| from astrbot.core.conversation_mgr import ConversationManager | ||
| from astrbot.core.cron import CronJobManager | ||
|
|
@@ -58,6 +61,7 @@ def __init__(self, log_broker: LogBroker, db: BaseDatabase) -> None: | |
|
|
||
| self.subagent_orchestrator: SubAgentOrchestrator | None = None | ||
| self.cron_manager: CronJobManager | None = None | ||
| self.auto_update_manager: AutoUpdateManager | None = None | ||
| self.temp_dir_cleaner: TempDirCleaner | None = None | ||
| self._default_chat_provider_warning_emitted = False | ||
|
|
||
|
|
@@ -255,6 +259,26 @@ async def initialize(self) -> None: | |
| # 初始化更新器 | ||
| self.astrbot_updator = AstrBotUpdator() | ||
|
|
||
| # 初始化自动更新管理器 | ||
| exporter = AstrBotExporter( | ||
| main_db=self.db, | ||
| kb_manager=self.kb_manager, | ||
| ) | ||
| importer = AstrBotImporter( | ||
| main_db=self.db, | ||
| kb_manager=self.kb_manager, | ||
| ) | ||
| self.auto_update_manager = AutoUpdateManager( | ||
| core_lifecycle=self, | ||
| db=self.db, | ||
| astrbot_config=self.astrbot_config, | ||
| updator=self.astrbot_updator, | ||
| cron_manager=self.cron_manager, | ||
| exporter=exporter, | ||
| importer=importer, | ||
| ) | ||
| await self.auto_update_manager.initialize() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 自动更新管理器( 建议将 try:
await self.auto_update_manager.initialize()
except Exception as e:
logger.error(f"Failed to initialize AutoUpdateManager: {e}", exc_info=True) |
||
|
|
||
| # 初始化事件总线 | ||
| self.event_bus = EventBus( | ||
| self.event_queue, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在
DEFAULT_CONFIG中,应该只定义配置项的默认值,而不是配置项的元数据/Schema(如description、type、properties等)。如果将 Schema 直接放入
DEFAULT_CONFIG,会导致astrbot_config.get("auto_update")返回 Schema 字典,而不是实际的默认配置值。例如,当代码尝试获取enabled时,会得到一个表示 Schema 的字典(在 Python 中被评估为True),从而导致逻辑错误或类型崩溃。解决方案:
DEFAULT_CONFIG中仅保留默认值。auto_update的 Schema 元数据移至CONFIG_METADATA_3_SYSTEM(系统配置组)中。