Skip to content

Commit

Permalink
Version 1.7.1
Browse files Browse the repository at this point in the history
* There was an error on new installations preventing usage of the
  client entirely.
  • Loading branch information
acuteenvy committed Oct 29, 2023
1 parent 116dc33 commit f6d0188
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tlrc"
version = "1.7.0"
version = "1.7.1"
description = "A tldr client written in Rust"
categories = ["command-line-utilities"]
homepage = "https://github.com/tldr-pages/tlrc"
Expand Down
14 changes: 12 additions & 2 deletions src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,16 @@ impl<'a> Cache<'a> {
/// Find out what platforms are available.
fn get_platforms(&self) -> Result<Vec<OsString>> {
let mut result = vec![];
let read_dir = fs::read_dir(self.0.join(ENGLISH_DIR));

for entry in fs::read_dir(self.0.join(ENGLISH_DIR))? {
match &read_dir {
// Return an empty Vec if the cache does not exist
// in order not to fail.
Err(e) if e.kind() == io::ErrorKind::NotFound => return Ok(vec![]),
_ => {}
}

for entry in read_dir.unwrap() {
let entry = entry?;
let path = entry.path();
let platform = path.file_name().unwrap();
Expand All @@ -239,7 +247,9 @@ impl<'a> Cache<'a> {
fn get_platforms_and_check(&self, platform: &str) -> Result<Vec<OsString>> {
let platforms = self.get_platforms()?;

if platforms.iter().all(|x| x != platform) {
// The !platforms.is_empty() check is here to get a "page not found" error instead of "invalid platform"
// when `pages.en` does not exist (because the dir was named `pages` in previous versions).
if platforms.iter().all(|x| x != platform) && !platforms.is_empty() {
Err(Error::new(format!(
"platform '{platform}' does not exist.\n{} {}.",
Paint::new("Possible values:").bold(),
Expand Down
2 changes: 1 addition & 1 deletion tldr.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH "TLRC" "1" "2023-10-29" "tlrc 1.7.0" "tlrc manual"
.TH "TLRC" "1" "2023-10-29" "tlrc 1.7.1" "tlrc manual"
.nh
.ad l
.SH NAME
Expand Down

0 comments on commit f6d0188

Please sign in to comment.