Skip to content

Commit 9cad227

Browse files
committed
feat: Implement resource directory path management for i18n and set GitHub releases to draft.
1 parent 280f36c commit 9cad227

3 files changed

Lines changed: 24 additions & 11 deletions

File tree

.github/workflows/release-portable.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ jobs:
158158
with:
159159
tag_name: v${{ steps.get_version.outputs.VERSION }}
160160
name: "RClone Manager v${{ steps.get_version.outputs.VERSION }}"
161-
draft: false
161+
draft: true
162162
prerelease: false
163163
files: |
164164
*.zip

src-tauri/src/core/paths.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use log::info;
99
use serde::Serialize;
1010
use std::path::PathBuf;
11-
use tauri::{AppHandle, Manager};
11+
use tauri::AppHandle;
1212

1313
// ============================================================================
1414
// Portable Mode Helpers
@@ -38,6 +38,8 @@ pub struct AppPaths {
3838
pub cache_dir: PathBuf,
3939
/// Logs directory (application logs)
4040
pub logs_dir: PathBuf,
41+
/// Resource directory (i18n, assets)
42+
pub resource_dir: PathBuf,
4143
}
4244

4345
impl AppPaths {
@@ -60,6 +62,7 @@ impl AppPaths {
6062
config_dir,
6163
cache_dir,
6264
logs_dir,
65+
resource_dir: exe_dir,
6366
})
6467
}
6568

@@ -68,6 +71,7 @@ impl AppPaths {
6871
/// Uses system directories via Tauri's path resolver.
6972
#[cfg(not(feature = "portable"))]
7073
pub fn from_app_handle(app: &AppHandle) -> Result<Self, String> {
74+
use tauri::Manager;
7175
// Get cache directory
7276
let cache_dir = app
7377
.path()
@@ -83,21 +87,31 @@ impl AppPaths {
8387
// Logs are stored in cache/logs
8488
let logs_dir = config_dir.join("logs");
8589

90+
// Resource directory
91+
let resource_dir = tauri::Manager::path(app)
92+
.resource_dir()
93+
.map_err(|e| format!("Failed to get resource directory: {}", e))?;
94+
8695
Ok(Self {
8796
config_dir,
8897
cache_dir,
8998
logs_dir,
99+
resource_dir,
90100
})
91101
}
92102

93103
/// Setup application paths and ensure directories exist
94104
///
95105
/// This is the main entry point for initializing paths during app startup.
96106
/// Returns the config directory path for backwards compatibility.
97-
pub fn setup(app: &AppHandle) -> Result<PathBuf, String> {
107+
/// Setup application paths and ensure directories exist
108+
///
109+
/// This is the main entry point for initializing paths during app startup.
110+
/// Returns the complete AppPaths struct.
111+
pub fn setup(app: &AppHandle) -> Result<Self, String> {
98112
let paths = Self::from_app_handle(app)?;
99113
paths.ensure_dirs()?;
100-
Ok(paths.config_dir)
114+
Ok(paths)
101115
}
102116

103117
/// Ensure all directories exist

src-tauri/src/lib.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,8 @@ fn setup_app(
276276
#[cfg(feature = "web-server")] cli_args: crate::core::cli::CliArgs,
277277
) -> Result<(), Box<dyn std::error::Error>> {
278278
let app_handle = app.handle();
279-
let config_dir = AppPaths::setup(app_handle)?;
279+
let app_paths = AppPaths::setup(app_handle)?;
280+
let config_dir = app_paths.config_dir;
280281

281282
// -------------------------------------------------------------------------
282283
// Initialize rcman Settings Manager
@@ -358,13 +359,11 @@ fn setup_app(
358359
// -------------------------------------------------------------------------
359360
// Initialize Backend i18n (before managing rcman_manager)
360361
// -------------------------------------------------------------------------
361-
if let Ok(resource_dir) = app_handle.path().resource_dir() {
362-
crate::utils::i18n::init(resource_dir);
362+
crate::utils::i18n::init(app_paths.resource_dir);
363363

364-
// Set initial language from settings
365-
if let Ok(lang) = rcman_manager.get::<String>("general.language") {
366-
crate::utils::i18n::set_language(&lang);
367-
}
364+
// Set initial language from settings
365+
if let Ok(lang) = rcman_manager.get::<String>("general.language") {
366+
crate::utils::i18n::set_language(&lang);
368367
}
369368

370369
// -------------------------------------------------------------------------

0 commit comments

Comments
 (0)