Skip to content

Commit

Permalink
fix(core): hard code BaseDirectory integer values to avoid regressi…
Browse files Browse the repository at this point in the history
…ons when reordering the variants (#11645)

closes #11633
  • Loading branch information
amrbashir authored Nov 11, 2024
1 parent 5e94354 commit e8a50f6
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 47 deletions.
6 changes: 6 additions & 0 deletions .changes/home-dir-regression.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"tauri": "patch:bug"
"@tauri-apps/api": "patch:bug"
---

Fix integer values of `BasDirectory.Home` and `BaseDirectory.Font` regression which broke path APIs in JS.
47 changes: 23 additions & 24 deletions crates/tauri/src/path/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,61 +85,60 @@ pub enum BaseDirectory {
/// The Audio directory.
Audio = 1,
/// The Cache directory.
Cache,
Cache = 2,
/// The Config directory.
Config,
Config = 3,
/// The Data directory.
Data,
Data = 4,
/// The LocalData directory.
LocalData,
LocalData = 5,
/// The Document directory.
Document,
Document = 6,
/// The Download directory.
Download,
Download = 7,
/// The Picture directory.
Picture,
Picture = 8,
/// The Public directory.
Public,
Public = 9,
/// The Video directory.
Video,
Video = 10,
/// The Resource directory.
Resource,
Resource = 11,
/// A temporary directory. Resolves to [`std::env::temp_dir`].
Temp,
Temp = 12,
/// The default app config directory.
/// Resolves to [`BaseDirectory::Config`]`/{bundle_identifier}`.
AppConfig,
AppConfig = 13,
/// The default app data directory.
/// Resolves to [`BaseDirectory::Data`]`/{bundle_identifier}`.
AppData,
AppData = 14,
/// The default app local data directory.
/// Resolves to [`BaseDirectory::LocalData`]`/{bundle_identifier}`.
AppLocalData,
AppLocalData = 15,
/// The default app cache directory.
/// Resolves to [`BaseDirectory::Cache`]`/{bundle_identifier}`.
AppCache,
AppCache = 16,
/// The default app log directory.
/// Resolves to [`BaseDirectory::Home`]`/Library/Logs/{bundle_identifier}` on macOS
/// and [`BaseDirectory::Config`]`/{bundle_identifier}/logs` on linux and Windows.
AppLog,
/// The Home directory.
Home,

AppLog = 17,
/// The Desktop directory.
#[cfg(not(target_os = "android"))]
Desktop,
Desktop = 18,
/// The Executable directory.
#[cfg(not(target_os = "android"))]
Executable,
Executable = 19,
/// The Font directory.
#[cfg(not(target_os = "android"))]
Font,
Font = 20,
/// The Home directory.
Home = 21,
/// The Runtime directory.
#[cfg(not(target_os = "android"))]
Runtime,
Runtime = 22,
/// The Template directory.
#[cfg(not(target_os = "android"))]
Template,
Template = 23,
}

impl BaseDirectory {
Expand Down
45 changes: 22 additions & 23 deletions packages/api/src/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,28 @@ import { invoke } from './core'
*/
enum BaseDirectory {
Audio = 1,
Cache,
Config,
Data,
LocalData,
Document,
Download,
Picture,
Public,
Video,
Resource,
Temp,
AppConfig,
AppData,
AppLocalData,
AppCache,
AppLog,

Desktop,
Executable,
Font,
Home,
Runtime,
Template
Cache = 2,
Config = 3,
Data = 4,
LocalData = 5,
Document = 6,
Download = 7,
Picture = 8,
Public = 9,
Video = 10,
Resource = 11,
Temp = 12,
AppConfig = 13,
AppData = 14,
AppLocalData = 15,
AppCache = 16,
AppLog = 17,
Desktop = 18,
Executable = 19,
Font = 20,
Home = 21,
Runtime = 22,
Template = 23
}

/**
Expand Down

0 comments on commit e8a50f6

Please sign in to comment.