CH-J Toolsquản lý máy chủ qua SSH
Menu
Mã nguồn đã công bố

CH-J Tools

Duyệt thư mục và tệp của một bản phát hành ứng dụng cụ thể.

Tải mã nguồn dạng ZIP
CH-J / Server Manager 1704 tệp
0.1.2-beta Ngày thêm: · Ngày dựng:
updates.rs Ngày thêm: Chưa ghi nhận ngày 2,8 KB · 67 dòng
Mã Tải tệp xuống
1//! Core update commands. The UI never passes a path, key or verification flag.
3use super::{logged, main_core, text, CommandResult};
4use crate::core::app::CoreSlot;
5use crate::core::error::CoreError;
6use serde_json::{json, Value};
7use tauri::{State, Webview};
9#[tauri::command]
10pub async fn core_updates_get_state(webview: Webview, slot: State<'_, CoreSlot>) -> CommandResult {
11 Ok(main_core(&webview, &slot)?.services.updates.get_state())
14#[tauri::command]
15pub async fn core_updates_check(webview: Webview, slot: State<'_, CoreSlot>) -> CommandResult {
16 let core = main_core(&webview, &slot)?;
17 let result = core.services.updates.check().await;
18 logged(&core, "updates:check", result)
21#[tauri::command]
22pub async fn core_updates_select(webview: Webview, slot: State<'_, CoreSlot>, payload: Option<Value>) -> CommandResult {
23 let core = main_core(&webview, &slot)?;
24 let payload = super::payload(payload);
25 logged(&core, "updates:select", core.services.updates.select(text(&payload, "id")))
28#[tauri::command]
29pub async fn core_updates_download(webview: Webview, slot: State<'_, CoreSlot>) -> CommandResult {
30 let core = main_core(&webview, &slot)?;
31 let result = core.services.updates.download().await;
32 logged(&core, "updates:download", result)
35#[tauri::command]
36pub async fn core_updates_install(webview: Webview, slot: State<'_, CoreSlot>) -> CommandResult {
37 let core = main_core(&webview, &slot)?;
38 let result = async {
39 core.services.biometrics.require_sensitive_action().await?;
40 // Re-hash and re-verify the internally tracked artifact right before launching it.
41 let path = core.services.updates.prepare_installer_launch().await?;
42 let launched = crate::core::updates::launcher::install(&core.app, &path, &core.logger).await?;
43 core.services.updates.mark_installer_launched()?;
44 if launched.restart {
45 let app = core.app.clone();
46 tauri::async_runtime::spawn(async move {
47 tokio::time::sleep(std::time::Duration::from_millis(250)).await;
48 app.restart();
49 });
50 }
51 Ok(json!({ "ok": true, "installed": launched.installed, "restarting": launched.restart }))
52 }
53 .await;
54 logged(&core, "updates:install", result)
57#[tauri::command]
58pub async fn core_updates_reveal(webview: Webview, slot: State<'_, CoreSlot>) -> CommandResult {
59 let core = main_core(&webview, &slot)?;
60 let result = (|| {
61 let path = core.services.updates.verified_download_path().ok_or_else(|| CoreError::plain("No verified update has been downloaded."))?;
62 use tauri_plugin_opener::OpenerExt;
63 core.app.opener().reveal_item_in_dir(&path).map_err(|e| CoreError::plain(e.to_string()))?;
64 Ok(json!({ "ok": true }))
65 })();
66 logged(&core, "updates:reveal", result)
SHA-256b1468c813e30cb317bd000289d8164d74e2b47b1dbc204639e348ac49a61c017

CH-J Proprietary Software License 1.14 · Mã nguồn được cung cấp theo CH-J Proprietary Software License 1.14. Việc công khai mã nguồn không thay đổi các điều khoản giấy phép và không cấp thêm quyền nào.

SHA-256 của tệp nénac8fe790f4ba60fc098f8c985fc2656cfcc6cdc21fb34b30e308a2b54e62258f
Tệp