Skip to content

Commit

Permalink
fix: don't auto create config directory unless generating instances file
Browse files Browse the repository at this point in the history
  • Loading branch information
sarowish committed Dec 14, 2022
1 parent e1a0167 commit 6ce6ecc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- No longer crashes if no tag is selected when trying to modify channels of a tag.
- Reload channels when a tag is deleted.
- Don't automatically create config directory unless generating instances file.

## [0.3.1] - 2022-10-16
### Fixed
Expand Down
2 changes: 1 addition & 1 deletion src/config/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl Options {
self.tick_rate = *tick_rate;
}

if let Some(request_timeout) = CLAP_ARGS.get_one::<u64>("instances") {
if let Some(request_timeout) = CLAP_ARGS.get_one::<u64>("request_timeout") {
self.request_timeout = *request_timeout;
}

Expand Down
10 changes: 7 additions & 3 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ pub fn get_config_dir() -> Result<PathBuf> {
Some(path) => path.join(PACKAGE_NAME),
None => bail!("Couldn't find config directory"),
};
if !path.exists() {
std::fs::create_dir_all(&path)?;
}

Ok(path)
}

Expand Down Expand Up @@ -59,6 +57,12 @@ pub fn get_default_instances_file() -> Result<PathBuf> {
pub fn generate_instances_file() -> Result<()> {
let instances = fetch_invidious_instances()?;
let instances_file_path = &CONFIG.options.instances;
let instances_dir = instances_file_path.parent().unwrap();

if !instances_dir.exists() {
std::fs::create_dir_all(instances_dir)?;
}

let mut file = File::create(instances_file_path.as_path())?;
println!(
"Generated \"{}\" with the following instances:",
Expand Down

0 comments on commit 6ce6ecc

Please sign in to comment.