Repository navigation
插件运行时清理与签到备份体验修复 #557
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
base: beta
Are you sure you want to change the base?
插件运行时清理与签到备份体验修复 #557
Changes from all commits
55522e4
bbc49bb
ac71807
c6bde71
91a546c
ac9b331
dc236f5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,6 +45,7 @@ | |
| "Agent2API · 多提供商本地网关": "Agent2API · マルチプロバイダーのローカルゲートウェイ", | ||
| "Agent2API 官方提供商": "", | ||
| "Agent2API 社区": "Agent2API コミュニティ", | ||
| "Bun 运行时已清理,下次使用脚本插件时自动重新下载": "Bun ランタイムをクリーンアップしました。次にスクリプトプラグインを使用すると自動で再ダウンロードされます", | ||
|
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.
|
||
| "Codar(科搭)": "Codar(科搭)", | ||
| "JoyCode(京东)": "JoyCode(京東)", | ||
| "Linux (amd64)": "Linux (amd64)", | ||
|
|
@@ -316,6 +317,9 @@ | |
| "尚未检查更新": "更新未確認", | ||
| "尚未登录": "まだログインしていません", | ||
| "已下载": "ダウンロード済み", | ||
| "清理 Bun 运行时": "Bun ランタイムをクリア", | ||
| "Bun 运行时已清理,下次使用脚本插件时自动重新下载": "Bun ランタイムをクリアしました。次にスクリプトプラグインを使用したときに自動で再ダウンロードします", | ||
| "清理中…": "クリア中…", | ||
| "已下载,待安装": "ダウンロード済み・インストール待ち", | ||
| "已修改 {n} 个模型": "{n} 個のモデルを変更しました", | ||
| "已修改 {n} 个账号": "{n} 個のアカウントを変更しました", | ||
|
|
@@ -585,6 +589,8 @@ | |
| "正在校验包内容…": "パッケージを検証中…", | ||
| "正在检查…": "確認中…", | ||
| "正在检查或准备脚本运行环境。": "スクリプト実行環境を確認・準備しています。", | ||
| "正在清理 Bun 运行时": "Bun ランタイムをクリーンアップ中", | ||
| "正在清理…": "クリーンアップ中…", | ||
| "正在自动补齐官方插件,不受日常更新开关和通道限制。": "通常の更新設定やチャンネルに関係なく、公式プラグインを必要なバージョンに自動更新しています。", | ||
| "正在补齐插件…": "必要なプラグインを更新中…", | ||
| "正在识别二维码…": "QR コードを認識中…", | ||
|
|
@@ -621,6 +627,11 @@ | |
| "添加": "追加", | ||
| "添加失败": "追加に失敗しました", | ||
| "添加服务器": "サーバーを追加", | ||
| "清单不是合法 JSON,作者修复后会自动恢复": "マニフェストは有効な JSON ではありません。作者が修正すると自動的に復元されます", | ||
| "清单更新于 {time}": "一覧の更新:{time}", | ||
| "清理 Bun 运行时": "Bun ランタイムをクリーンアップ", | ||
| "清理失败": "クリーンアップに失敗", | ||
| "清理运行时": "ランタイムをクリーンアップ", | ||
| "清空 = 回到内置默认(与「恢复默认」等价)。": "空にすると組み込みの既定に戻ります(「デフォルトに戻す」と同じ)。", | ||
| "清除失败:{error}": "削除に失敗しました:{error}", | ||
| "点「编辑」弹窗改内容;开关关掉就整段不发。": "「編集」をクリックするとダイアログで内容を変更できます。スイッチを切ると丸ごと送信されません。", | ||
|
|
@@ -764,6 +775,9 @@ | |
| "输入这台网关的管理员账号与密码。": "このゲートウェイの管理者アカウントとパスワードを入力してください。", | ||
| "运行日志": "", | ||
| "运行时不内置于安装包,首次安装脚本插件时自动下载并校验。": "ランタイムはインストーラーに含まれません。スクリプトプラグインの初回インストール時に自動でダウンロードし、検証します。", | ||
| "运行时清理未完成": "ランタイムのクリーンアップが完了していません", | ||
| "运行日志": "実行ログ", | ||
| "运行时清理超时,请稍后刷新状态重试": "ランタイムのクリーンアップがタイムアウトしました。しばらくしてから状態を更新して再試行してください", | ||
| "运行正常 · {url}": "正常稼働中 · {url}", | ||
| "运行状态": "稼働状態", | ||
| "返回": "", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -89,12 +89,14 @@ pub fn snapshot() -> Value { | |
| } | ||
| } | ||
|
|
||
| pub async fn ensure() -> Result<PathBuf, String> { | ||
| /// 下载与清理共用同一把互斥锁:删除运行时目录不能与按需下载并发 | ||
| fn download_lock() -> &'static tokio::sync::Mutex<()> { | ||
| static LOCK: OnceLock<tokio::sync::Mutex<()>> = OnceLock::new(); | ||
| let _guard = LOCK | ||
| .get_or_init(|| tokio::sync::Mutex::new(())) | ||
| .lock() | ||
| .await; | ||
| LOCK.get_or_init(|| tokio::sync::Mutex::new(())) | ||
| } | ||
|
|
||
| pub async fn ensure() -> Result<PathBuf, String> { | ||
| let _guard = download_lock().lock().await; | ||
| let path = installed()?; | ||
| if path.is_file() { | ||
| validate(&path).await?; | ||
|
|
@@ -113,6 +115,22 @@ pub async fn ensure() -> Result<PathBuf, String> { | |
| Ok(path) | ||
| } | ||
|
|
||
| /// 删除整个运行时目录(含全部版本),供启动失败后的重置入口调用, | ||
| /// 下次使用脚本插件时按需重新下载,目录不存在视为已清理 | ||
| pub async fn clean() -> Result<(), String> { | ||
| let _guard = download_lock().lock().await; | ||
| let root = crate::server::config::config_dir() | ||
| .join("runtimes") | ||
| .join("bun"); | ||
| tokio::task::spawn_blocking(move || match std::fs::remove_dir_all(&root) { | ||
| Ok(()) => Ok(()), | ||
| Err(error) if error.kind() == std::io::ErrorKind::NotFound => Ok(()), | ||
| Err(error) => Err(format!("Bun 运行时目录清理失败:{error}")), | ||
| }) | ||
| .await | ||
| .map_err(|error| format!("清理 Bun 运行时任务中断:{error}"))? | ||
| } | ||
|
Comment on lines
+120
to
+132
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.
|
||
|
|
||
| async fn validate(path: &Path) -> Result<(), String> { | ||
| let result = probe(path).await; | ||
| if let Ok(mut saved) = last_error().lock() { | ||
|
|
||
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.
Script executed:
Repository: aimod-cc/Agent2API
Length of output: 512
Script executed:
Repository: aimod-cc/Agent2API
Length of output: 10492
Script executed:
Repository: aimod-cc/Agent2API
Length of output: 10285
Script executed:
Repository: aimod-cc/Agent2API
Length of output: 11296
Script executed:
Repository: aimod-cc/Agent2API
Length of output: 13885
删除重复的词典 key。
JSON.parse会保留后面的译文。因此,修改第 49 行不会影响清理成功提示。清理 Bun 运行时也重复了一次,但两处译文相同。每个 key 保留一条,并确认保留的译文。以下改动保留当前生效的译文:
删除重复项
Committable suggestion
Biome (2.5.15)
[error] 49-49: The key Bun 运行时已清理,下次使用脚本插件时自动重新下载 was already declared.
(lint/suspicious/noDuplicateObjectKeys)