CH-J Toolsgerenciamento de servidor sobre SSH
E-mail
Fonte publicada

CH-J Tools

Navegue por diretórios e arquivos para uma versão específica do aplicativo.

Transferir fonte ZIP
CH-J / Server Manager 1704 arquivos
0.1.2-beta Adicionado: · Construído:
paths.rs Adicionado: Data não registada 3,1 KB · 72 linhas
Código Transferir ficheiro
1//! Data and resource locations.
2//!
3//! Up to 0.1.2 development the application was called "CH-J Server Manager" and (0.1.1 deliberately
4//! keeping the Electron 0.1.0 `userData`) stored its data in a folder of that name. Since the rename to
5//! CH-J Tools the folder is:
6//! * macOS: ~/Library/Application Support/CH-J Tools
7//! * Windows: %APPDATA%\CH-J Tools
8//! * Linux: $XDG_CONFIG_HOME/CH-J Tools (default ~/.config/…)
9//!
10//! The first start moves the old folder there in one rename (see `migration::adopt_renamed_directory`), so the
11//! existing vault, profiles, settings, modules and history are kept. The Standby Helper resolves the same way.
13use std::path::{Path, PathBuf};
15pub const APP_DIRECTORY_NAME: &str = "CH-J Tools";
16/// Data folder of "CH-J Server Manager" (Electron 0.1.0, Tauri 0.1.1 and 0.1.2 before the rename).
17pub const LEGACY_APP_DIRECTORY_NAME: &str = "CH-J Server Manager";
18/// Test/smoke override (absolute path only), same variable name as in 0.1.0 plus a neutral alias.
19pub const USER_DATA_OVERRIDE_VARS: [&str; 2] = ["CHJ_USER_DATA_DIR", "CHJ_BUILD_SMOKE_USER_DATA_DIR"];
21#[derive(Clone, Debug)]
22pub struct AppPaths {
23 /// User data root (identical to Electron 0.1.0 `userData`).
24 pub data: PathBuf,
25 /// Bundled resources (licenses, docs, remote scripts, native helpers, modules).
26 pub resources: PathBuf,
27 /// What happened to the old "CH-J Server Manager" folder at this start (logged once the logger exists).
28 pub relocation: Option<crate::core::migration::Relocation>,
31impl AppPaths {
32 /// `stop_helper` is called with the old folder when renaming it fails, before the one retry (Windows keeps a
33 /// running helper's open files locked).
34 pub fn resolve(config_dir: Option<PathBuf>, resources: PathBuf, stop_helper: impl Fn(&Path)) -> Result<Self, String> {
35 for var in USER_DATA_OVERRIDE_VARS {
36 if let Ok(value) = std::env::var(var) {
37 let path = PathBuf::from(value);
38 if path.is_absolute() {
39 return Ok(Self { data: path, resources, relocation: None });
40 }
41 }
42 }
43 let base = config_dir.ok_or("The user configuration directory is unavailable.")?;
44 let (data, relocation) = crate::core::migration::adopt_renamed_directory(&base, APP_DIRECTORY_NAME, LEGACY_APP_DIRECTORY_NAME, stop_helper);
45 Ok(Self { data, resources, relocation })
46 }
48 pub fn remote_script(&self, name: &str) -> PathBuf {
49 self.resources.join("remote").join(name)
50 }
52 pub fn docs(&self) -> PathBuf {
53 self.resources.join("docs")
54 }
56 pub fn licenses(&self) -> PathBuf {
57 self.resources.join("licenses")
58 }
60 pub fn bundled_modules(&self) -> PathBuf {
61 self.resources.join("modules")
62 }
64 /// WebView data of each module window before they shared one WebView; removed at start.
65 pub fn legacy_module_webview_data(&self) -> PathBuf {
66 self.data.join("webview").join("modules")
67 }
69 pub fn in_data(&self, relative: impl AsRef<Path>) -> PathBuf {
70 self.data.join(relative)
71 }
SHA-256d4a4e6e628b6ac6a6e2b30513ef9a2a266818608aee8ced4f666938bfc46b2e8

CH-J Proprietary Software License 1.14 · A fonte é fornecida sob o CH-J Proprietary Software License 1.14. A sua disponibilidade não altera os termos licença nem concede direitos adicionais.

Ficheiro SHA-256ac8fe790f4ba60fc098f8c985fc2656cfcc6cdc21fb34b30e308a2b54e62258f
Ficheiros