From 24b3a8857625e57107fc1aee1ea98b26fc859618 Mon Sep 17 00:00:00 2001 From: Christian Zangl Date: Sun, 18 Aug 2024 16:05:33 +0200 Subject: [PATCH] fix status --- cmd/chkbit/main.go | 17 ++++++++++------- scripts/run_test_prep | 2 +- scripts/run_tests | 4 ++-- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/cmd/chkbit/main.go b/cmd/chkbit/main.go index 540dc19..ee2f832 100644 --- a/cmd/chkbit/main.go +++ b/cmd/chkbit/main.go @@ -25,7 +25,7 @@ const ( ) const ( - updateInterval = time.Millisecond * 300 + updateInterval = time.Millisecond * 700 sizeMB int64 = 1024 * 1024 ) @@ -80,7 +80,7 @@ func (m *Main) log(text string) { m.logger.Println(time.Now().UTC().Format("2006-01-02 15:04:05"), text) } -func (m *Main) logStatus(stat chkbit.Status, path string) { +func (m *Main) logStatus(stat chkbit.Status, path string) bool { if stat == chkbit.STATUS_UPDATE_INDEX { m.numIdxUpd++ } else { @@ -108,8 +108,10 @@ func (m *Main) logStatus(stat chkbit.Status, path string) { col = termAlertFG } lterm.Printline(col, stat.String(), " ", path, lterm.Reset) + return true } } + return false } func (m *Main) showStatus(context *chkbit.Context) { @@ -124,11 +126,12 @@ func (m *Main) showStatus(context *chkbit.Context) { } return } - m.logStatus(item.Stat, item.Message) - if m.progress == Fancy { - lterm.Write(termBG, termFG1, stat, lterm.ClearLine(0), lterm.Reset, "\r") - } else { - fmt.Print(m.total, "\r") + if m.logStatus(item.Stat, item.Message) { + if m.progress == Fancy { + lterm.Write(termBG, termFG1, stat, lterm.ClearLine(0), lterm.Reset, "\r") + } else { + fmt.Print(m.total, "\r") + } } case perf := <-context.PerfQueue: now := time.Now() diff --git a/scripts/run_test_prep b/scripts/run_test_prep index 2c139aa..f8d561a 100755 --- a/scripts/run_test_prep +++ b/scripts/run_test_prep @@ -10,4 +10,4 @@ mv $root/root/people $root/people ln -s ../people people ln -s ../../people/face/office-door.pdf day/friend/office-door.pdf -find -L | wc -l +find -L -type f | wc -l diff --git a/scripts/run_tests b/scripts/run_tests index fb708b5..fe0537d 100755 --- a/scripts/run_tests +++ b/scripts/run_tests @@ -16,6 +16,6 @@ fi $script_dir/build -"$base_dir/chkbit" -u /tmp/chkbit -# todo: validate +"$base_dir/chkbit" -u /tmp/chkbit/root +# todo: validate (300 files, 1 symlink dir followed, 1 symlink file ignored)