+
Skip to content
This repository was archived by the owner on Sep 17, 2024. It is now read-only.

fix: empty flavor folders #533

Merged
merged 5 commits into from
Feb 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ and `Removed`.
### Fixed

- Multiple error messages are now correctly localized.
- Corrected error in flavor detection if Ajour was launched before WoW had ever
been launched.

## [0.7.0] - 2021-01-26

Expand Down
21 changes: 14 additions & 7 deletions crates/core/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use glob::MatchOptions;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::fmt::{self, Display, Formatter};
use std::fs::create_dir_all;
use std::path::PathBuf;

mod addons;
Expand Down Expand Up @@ -60,9 +61,11 @@ impl Config {
/// This will return `None` if no `wow_directory` is set in the config.
pub fn get_addon_directory_for_flavor(&self, flavor: &Flavor) -> Option<PathBuf> {
match &self.wow.directory {
Some(dir) => {
// The path to the directory containing the addons
let mut addon_dir = dir.join(&flavor.folder_name()).join("Interface/AddOns");
Some(wow_dir) => {
// The path to the flavor directory
let flavor_dir = wow_dir.join(&flavor.folder_name());
// The path to the addons directory
let mut addon_dir = flavor_dir.join("Interface/AddOns");

// If path doesn't exist, it could have been modified by the user.
// Check for a case-insensitive version and use that instead.
Expand All @@ -74,10 +77,7 @@ impl Config {

// For some reason the case insensitive pattern doesn't work
// unless we add an actual pattern symbol, hence the `?`.
let pattern = format!(
"{}/?nterface/?ddons",
dir.join(&flavor.folder_name()).display()
);
let pattern = format!("{}/?nterface/?ddons", flavor_dir.display());

for entry in glob::glob_with(&pattern, options).unwrap() {
if let Ok(path) = entry {
Expand All @@ -86,6 +86,13 @@ impl Config {
}
}

// If flavor dir exists but not addon dir we try to create it.
// This state can happen if you do a fresh install of WoW and
// launch Ajour before you launch WoW.
if flavor_dir.exists() && !addon_dir.exists() {
let _ = create_dir_all(&addon_dir);
}

Some(addon_dir)
}
None => None,
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载