fix: ya pkg fails to write package.toml when the config directory does not exist (#3482)

Co-authored-by: sxyazi <sxyazi@gmail.com>
This commit is contained in:
Integral 2026-01-01 09:25:23 +08:00 committed by GitHub
parent 456b88d660
commit 0000141700
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 3 deletions

View file

@ -16,6 +16,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
- Support VFS for preset previewers that rely on external commands ([#3477])
### Fixed
- `ya pkg` fails to write `package.toml` when the config directory does not exist ([#3482])
## [v25.12.29]
### Added
@ -1571,3 +1575,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
[#3456]: https://github.com/sxyazi/yazi/pull/3456
[#3467]: https://github.com/sxyazi/yazi/pull/3467
[#3477]: https://github.com/sxyazi/yazi/pull/3477
[#3482]: https://github.com/sxyazi/yazi/pull/3482

View file

@ -4,9 +4,13 @@ use anyhow::Context;
use yazi_fs::Xdg;
pub(super) fn init() -> anyhow::Result<()> {
let root = Xdg::state_dir().join("packages");
std::fs::create_dir_all(&root)
.with_context(|| format!("failed to create packages directory: {root:?}"))?;
let packages_dir = Xdg::state_dir().join("packages");
std::fs::create_dir_all(&packages_dir)
.with_context(|| format!("failed to create packages directory: {packages_dir:?}"))?;
let config_dir = Xdg::config_dir();
std::fs::create_dir_all(&config_dir)
.with_context(|| format!("failed to create config directory: {config_dir:?}"))?;
Ok(())
}