Skip to content

Commit

Permalink
fix status
Browse files Browse the repository at this point in the history
  • Loading branch information
laktak committed Aug 18, 2024
1 parent 90b406b commit 24b3a88
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
17 changes: 10 additions & 7 deletions cmd/chkbit/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const (
)

const (
updateInterval = time.Millisecond * 300
updateInterval = time.Millisecond * 700
sizeMB int64 = 1024 * 1024
)

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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) {
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion scripts/run_test_prep
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions scripts/run_tests
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 24b3a88

Please sign in to comment.