Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit eeae2bc

Browse files
committed
Fix file count
1 parent 96ef242 commit eeae2bc

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

src/interactive/widgets/entries.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ fn title_block(title: &str, border_style: Style) -> Block<'_> {
157157

158158
fn title(current_path: &str, item_count: u64, display: DisplayOptions, size: u128) -> String {
159159
format!(
160-
" {} ({} item{}, {}) ",
160+
" {} ({} file{}, {}) ",
161161
current_path,
162162
COUNT.format(item_count as f64),
163163
match item_count {

src/traverse.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,13 +270,15 @@ impl BackgroundTraversal {
270270

271271
let mut file_size = 0u128;
272272
let mut mtime: SystemTime = UNIX_EPOCH;
273+
let mut file_count = 0u64;
273274
match &entry.client_state {
274275
Some(Ok(ref m)) => {
275276
if !m.is_dir()
276277
&& (self.walk_options.count_hard_links || self.inodes.add(m))
277278
&& (self.walk_options.cross_filesystems
278279
|| crossdev::is_same_device(device_id, m))
279280
{
281+
file_count = 1;
280282
if self.walk_options.apparent_size {
281283
file_size = m.len() as u128;
282284
} else {
@@ -316,7 +318,7 @@ impl BackgroundTraversal {
316318
.push(self.current_directory_at_depth);
317319
self.current_directory_at_depth = EntryInfo {
318320
size: file_size,
319-
entries_count: Some(1),
321+
entries_count: Some(file_count),
320322
};
321323
self.parent_node_idx = self.previous_node_idx;
322324
}
@@ -340,7 +342,7 @@ impl BackgroundTraversal {
340342
*self
341343
.current_directory_at_depth
342344
.entries_count
343-
.get_or_insert(0) += 1;
345+
.get_or_insert(0) += file_count;
344346
set_entry_info_or_panic(
345347
&mut traversal.tree,
346348
self.parent_node_idx,
@@ -352,7 +354,7 @@ impl BackgroundTraversal {
352354
*self
353355
.current_directory_at_depth
354356
.entries_count
355-
.get_or_insert(0) += 1;
357+
.get_or_insert(0) += file_count;
356358
}
357359
};
358360

0 commit comments

Comments
 (0)