Skip to content

Commit e8a50f6

Browse files
authored
fix(core): hard code BaseDirectory integer values to avoid regressions when reordering the variants (#11645)
closes #11633
1 parent 5e94354 commit e8a50f6

File tree

3 files changed

+51
-47
lines changed

3 files changed

+51
-47
lines changed

.changes/home-dir-regression.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"tauri": "patch:bug"
3+
"@tauri-apps/api": "patch:bug"
4+
---
5+
6+
Fix integer values of `BasDirectory.Home` and `BaseDirectory.Font` regression which broke path APIs in JS.

crates/tauri/src/path/mod.rs

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -85,61 +85,60 @@ pub enum BaseDirectory {
8585
/// The Audio directory.
8686
Audio = 1,
8787
/// The Cache directory.
88-
Cache,
88+
Cache = 2,
8989
/// The Config directory.
90-
Config,
90+
Config = 3,
9191
/// The Data directory.
92-
Data,
92+
Data = 4,
9393
/// The LocalData directory.
94-
LocalData,
94+
LocalData = 5,
9595
/// The Document directory.
96-
Document,
96+
Document = 6,
9797
/// The Download directory.
98-
Download,
98+
Download = 7,
9999
/// The Picture directory.
100-
Picture,
100+
Picture = 8,
101101
/// The Public directory.
102-
Public,
102+
Public = 9,
103103
/// The Video directory.
104-
Video,
104+
Video = 10,
105105
/// The Resource directory.
106-
Resource,
106+
Resource = 11,
107107
/// A temporary directory. Resolves to [`std::env::temp_dir`].
108-
Temp,
108+
Temp = 12,
109109
/// The default app config directory.
110110
/// Resolves to [`BaseDirectory::Config`]`/{bundle_identifier}`.
111-
AppConfig,
111+
AppConfig = 13,
112112
/// The default app data directory.
113113
/// Resolves to [`BaseDirectory::Data`]`/{bundle_identifier}`.
114-
AppData,
114+
AppData = 14,
115115
/// The default app local data directory.
116116
/// Resolves to [`BaseDirectory::LocalData`]`/{bundle_identifier}`.
117-
AppLocalData,
117+
AppLocalData = 15,
118118
/// The default app cache directory.
119119
/// Resolves to [`BaseDirectory::Cache`]`/{bundle_identifier}`.
120-
AppCache,
120+
AppCache = 16,
121121
/// The default app log directory.
122122
/// Resolves to [`BaseDirectory::Home`]`/Library/Logs/{bundle_identifier}` on macOS
123123
/// and [`BaseDirectory::Config`]`/{bundle_identifier}/logs` on linux and Windows.
124-
AppLog,
125-
/// The Home directory.
126-
Home,
127-
124+
AppLog = 17,
128125
/// The Desktop directory.
129126
#[cfg(not(target_os = "android"))]
130-
Desktop,
127+
Desktop = 18,
131128
/// The Executable directory.
132129
#[cfg(not(target_os = "android"))]
133-
Executable,
130+
Executable = 19,
134131
/// The Font directory.
135132
#[cfg(not(target_os = "android"))]
136-
Font,
133+
Font = 20,
134+
/// The Home directory.
135+
Home = 21,
137136
/// The Runtime directory.
138137
#[cfg(not(target_os = "android"))]
139-
Runtime,
138+
Runtime = 22,
140139
/// The Template directory.
141140
#[cfg(not(target_os = "android"))]
142-
Template,
141+
Template = 23,
143142
}
144143

145144
impl BaseDirectory {

packages/api/src/path.ts

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,28 @@ import { invoke } from './core'
1818
*/
1919
enum BaseDirectory {
2020
Audio = 1,
21-
Cache,
22-
Config,
23-
Data,
24-
LocalData,
25-
Document,
26-
Download,
27-
Picture,
28-
Public,
29-
Video,
30-
Resource,
31-
Temp,
32-
AppConfig,
33-
AppData,
34-
AppLocalData,
35-
AppCache,
36-
AppLog,
37-
38-
Desktop,
39-
Executable,
40-
Font,
41-
Home,
42-
Runtime,
43-
Template
21+
Cache = 2,
22+
Config = 3,
23+
Data = 4,
24+
LocalData = 5,
25+
Document = 6,
26+
Download = 7,
27+
Picture = 8,
28+
Public = 9,
29+
Video = 10,
30+
Resource = 11,
31+
Temp = 12,
32+
AppConfig = 13,
33+
AppData = 14,
34+
AppLocalData = 15,
35+
AppCache = 16,
36+
AppLog = 17,
37+
Desktop = 18,
38+
Executable = 19,
39+
Font = 20,
40+
Home = 21,
41+
Runtime = 22,
42+
Template = 23
4443
}
4544

4645
/**

0 commit comments

Comments
 (0)