From 4c445649c41d5664887e143bd720fa896e97c52a Mon Sep 17 00:00:00 2001 From: amrbashir Date: Mon, 11 Nov 2024 14:20:10 +0200 Subject: [PATCH] fix(core): hard code `BaseDirectory` integer values to avoid regressions when reordering the variants closes #11633 --- .changes/home-dir-regression.md | 6 +++++ crates/tauri/src/path/mod.rs | 47 ++++++++++++++++----------------- packages/api/src/path.ts | 45 +++++++++++++++---------------- 3 files changed, 51 insertions(+), 47 deletions(-) create mode 100644 .changes/home-dir-regression.md diff --git a/.changes/home-dir-regression.md b/.changes/home-dir-regression.md new file mode 100644 index 000000000000..4f2de5531e93 --- /dev/null +++ b/.changes/home-dir-regression.md @@ -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. diff --git a/crates/tauri/src/path/mod.rs b/crates/tauri/src/path/mod.rs index 28854fb547ff..575fa926bfd6 100644 --- a/crates/tauri/src/path/mod.rs +++ b/crates/tauri/src/path/mod.rs @@ -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 { diff --git a/packages/api/src/path.ts b/packages/api/src/path.ts index dd81affd49eb..9e8e5e034756 100644 --- a/packages/api/src/path.ts +++ b/packages/api/src/path.ts @@ -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 } /**