nnn

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 025b570e05a441a1cb8e4ba132fa6b2b656c8ea9
parent db8079f552621ed3b1274f52eb0fc7caa47e94a5
Author: Arun Prakash Jana <engineerarun@gmail.com>
Date:   Wed, 26 May 2021 03:16:01 +0530

Fix du calculation

Diffstat:
Msrc/nnn.c | 12++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/nnn.c b/src/nnn.c @@ -4954,18 +4954,22 @@ static bool handle_cmd(enum action sel, const char *current, char *newpath) return TRUE; } -static int sum_bsize(const char *UNUSED(fpath), const struct stat *sb, int UNUSED(typeflag), struct FTW *UNUSED(ftwbuf)) +static int sum_bsize(const char *UNUSED(fpath), const struct stat *sb, int typeflag, struct FTW *UNUSED(ftwbuf)) { - if (sb->st_blocks && (sb->st_nlink <= 1 || test_set_bit((uint_t)sb->st_ino))) + if (sb->st_blocks + && ((typeflag == FTW_F && (sb->st_nlink <= 1 || test_set_bit((uint_t)sb->st_ino))) + || typeflag == FTW_D)) ent_blocks += sb->st_blocks; ++num_files; return 0; } -static int sum_asize(const char *UNUSED(fpath), const struct stat *sb, int UNUSED(typeflag), struct FTW *UNUSED(ftwbuf)) +static int sum_asize(const char *UNUSED(fpath), const struct stat *sb, int typeflag, struct FTW *UNUSED(ftwbuf)) { - if (sb->st_size && (sb->st_nlink <= 1 || test_set_bit((uint_t)sb->st_ino))) + if (sb->st_size + && ((typeflag == FTW_F && (sb->st_nlink <= 1 || test_set_bit((uint_t)sb->st_ino))) + || typeflag == FTW_D)) ent_blocks += sb->st_size; ++num_files;