Commit c864ec80 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 24ab091c
...@@ -53,7 +53,7 @@ type Dumper interface { ...@@ -53,7 +53,7 @@ type Dumper interface {
DumpTxn(buf *xfmt.Buffer, it *fs1.Iter) error DumpTxn(buf *xfmt.Buffer, it *fs1.Iter) error
// DumpEndOK is called at the end of successfull dump. // DumpEndOK is called at the end of successfull dump.
DumpEndOK(buf *xfmt.Buffer) DumpEndOK(buf *xfmt.Buffer) error
} }
// Dump dumps content of a FileStorage file @ path. // Dump dumps content of a FileStorage file @ path.
...@@ -123,7 +123,10 @@ func Dump(w io.Writer, path string, dir fs1.IterDir, d Dumper) (err error) { ...@@ -123,7 +123,10 @@ func Dump(w io.Writer, path string, dir fs1.IterDir, d Dumper) (err error) {
} }
} }
d.DumpEndOK(buf) err = d.DumpEndOK(buf)
if err != nil {
return err
}
return nil return nil
} }
...@@ -204,7 +207,8 @@ func (d *DumperFsDump) DumpTxn(buf *xfmt.Buffer, it *fs1.Iter) error { ...@@ -204,7 +207,8 @@ func (d *DumperFsDump) DumpTxn(buf *xfmt.Buffer, it *fs1.Iter) error {
} }
} }
func (d *DumperFsDump) DumpEndOK(buf *xfmt.Buffer) { func (d *DumperFsDump) DumpEndOK(buf *xfmt.Buffer) error {
return nil
} }
// DumperFsDumpVerbose implements a very verbose dumper with output identical // DumperFsDumpVerbose implements a very verbose dumper with output identical
...@@ -290,7 +294,8 @@ func (d *DumperFsDumpVerbose) dumpData(buf *xfmt.Buffer, it *fs1.Iter) error { ...@@ -290,7 +294,8 @@ func (d *DumperFsDumpVerbose) dumpData(buf *xfmt.Buffer, it *fs1.Iter) error {
return nil return nil
} }
func (d *DumperFsDumpVerbose) DumpEndOK(buf *xfmt.Buffer) { func (d *DumperFsDumpVerbose) DumpEndOK(buf *xfmt.Buffer) error {
return nil
} }
const dumpSummary = "dump database transactions" const dumpSummary = "dump database transactions"
...@@ -395,7 +400,8 @@ func (d *DumperFsTail) DumpTxn(buf *xfmt.Buffer, it *fs1.Iter) error { ...@@ -395,7 +400,8 @@ func (d *DumperFsTail) DumpTxn(buf *xfmt.Buffer, it *fs1.Iter) error {
return nil return nil
} }
func (d *DumperFsTail) DumpEndOK(buf *xfmt.Buffer) { func (d *DumperFsTail) DumpEndOK(buf *xfmt.Buffer) error {
return nil
} }
const tailSummary = "dump last few transactions of a database" const tailSummary = "dump last few transactions of a database"
......
...@@ -57,18 +57,25 @@ func Verify(w io.Writer, path string, verbose int, progress bool) (err error) { ...@@ -57,18 +57,25 @@ func Verify(w io.Writer, path string, verbose int, progress bool) (err error) {
tick := time.NewTicker(time.Second / 4) tick := time.NewTicker(time.Second / 4)
defer tick.Stop() defer tick.Stop()
v.progress = func(pos int64) error { xcr := ""
if verbose > 0 {
xcr = "\n"
}
v.progress = func(force bool) error {
if !force {
select { select {
case <-tick.C: case <-tick.C:
default: default:
return nil return nil
} }
}
_, err := fmt.Fprintf(w, _, err := fmt.Fprintf(w,
"\rVerified data bytes: %.1f%% (%d/%d); #txn: %d", "\rVerified data bytes: %.1f%% (%d/%d); #txn: %d%s",
100 * float64(pos) / float64(fsize), 100 * float64(v.donePos) / float64(fsize),
pos, fsize, v.donePos, fsize,
v.ntxn) v.ntxn,
xcr)
return err return err
} }
} }
...@@ -84,7 +91,8 @@ type Verifier struct { ...@@ -84,7 +91,8 @@ type Verifier struct {
// for loading data // for loading data
dhLoading fs1.DataHeader dhLoading fs1.DataHeader
progress func(pos int64) error donePos int64 // done verifying till this position
progress func(force bool) error
} }
func (v *Verifier) DumperName() string { func (v *Verifier) DumperName() string {
...@@ -130,7 +138,8 @@ func (v *Verifier) DumpTxn(buf *xfmt.Buffer, it *fs1.Iter) error { ...@@ -130,7 +138,8 @@ func (v *Verifier) DumpTxn(buf *xfmt.Buffer, it *fs1.Iter) error {
v.ntxn++ v.ntxn++
if v.progress != nil { if v.progress != nil {
err := v.progress(txnh.Pos) v.donePos = txnh.Pos + txnh.Len
err := v.progress(/*force=*/false)
if err != nil { if err != nil {
return err return err
} }
...@@ -139,10 +148,17 @@ func (v *Verifier) DumpTxn(buf *xfmt.Buffer, it *fs1.Iter) error { ...@@ -139,10 +148,17 @@ func (v *Verifier) DumpTxn(buf *xfmt.Buffer, it *fs1.Iter) error {
return nil return nil
} }
func (v *Verifier) DumpEndOK(buf *xfmt.Buffer) { func (v *Verifier) DumpEndOK(buf *xfmt.Buffer) error {
if v.progress != nil {
err := v.progress(/*force=*/true)
if err != nil {
return err
}
}
if v.verbose >= 1 { if v.verbose >= 1 {
buf .S("no errors detected\n") buf .S("no errors detected\n")
} }
return nil
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment