Skip to content

Commit

Permalink
Fix incorrect page counters when pages are deleted
Browse files Browse the repository at this point in the history
* The number of pages was an unsigned integer, but tldr pages can be
  deleted too
  • Loading branch information
acuteenvy committed Nov 4, 2023
1 parent 52210fe commit a677ad9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
9 changes: 5 additions & 4 deletions src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ impl<'a> Cache<'a> {
&self,
lang_dir: &str,
archive: &mut PagesArchive,
n_existing: usize,
all_downloaded: &mut usize,
all_new: &mut usize,
n_existing: i32,
all_downloaded: &mut i32,
all_new: &mut i32,
) -> Result<()> {
info_start!("extracting '{lang_dir}'...");

Expand Down Expand Up @@ -183,10 +183,11 @@ impl<'a> Cache<'a> {
self.clean()?;

for (lang_dir, mut archive) in archives {
#[allow(clippy::cast_possible_truncation, clippy::cast_possible_wrap)]
self.extract_lang_archive(
&lang_dir,
&mut archive,
*dirs_npages.get(&lang_dir).unwrap_or(&0),
(*dirs_npages.get(&lang_dir).unwrap_or(&0)) as i32,
&mut all_downloaded,
&mut all_new,
)?;
Expand Down
8 changes: 4 additions & 4 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,15 @@ pub fn languages_to_langdirs(languages: &[String]) -> Vec<String> {
pub fn init_color(color_mode: ColorChoice) {
#[cfg(target_os = "windows")]
let color_support = Paint::enable_windows_ascii();
#[cfg(not(target_os = "windows"))]
let color_support = true;

let no_color = env::var_os("NO_COLOR").is_some_and(|x| !x.is_empty());

match color_mode {
ColorChoice::Always => {}
ColorChoice::Never => Paint::disable(),
ColorChoice::Auto => {
#[cfg(not(target_os = "windows"))]
let color_support = true;
let no_color = env::var_os("NO_COLOR").is_some_and(|x| !x.is_empty());

if !(color_support && !no_color && io::stdout().is_terminal()) {
Paint::disable();
}
Expand Down

0 comments on commit a677ad9

Please sign in to comment.