Commit 3b04f1df authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent c22731dc
......@@ -91,7 +91,7 @@ func fsTail(w io.Writer, path string, ntxn int) (err error) {
}
// buffer for formatting
xbuf := xfmt.Buffer{}
buf := xfmt.Buffer{}
// now loop loading transactions backwards until EOF / ntxn limit
for i := ntxn; i > 0; i-- {
......@@ -115,20 +115,20 @@ func fsTail(w io.Writer, path string, ntxn int) (err error) {
}
// print information about read txn record
xbuf.Reset()
buf.Reset()
dataSha1 := sha1.Sum(data)
xbuf .V(txnh.Tid.Time()) .S(": hash=") .Xb(dataSha1[:])
buf .V(txnh.Tid.Time()) .S(": hash=") .Xb(dataSha1[:])
// fstail.py uses repr to print user/description:
// https://github.com/zopefoundation/ZODB/blob/5.2.0-5-g6047e2fae/src/ZODB/scripts/fstail.py#L39
xbuf .S("\nuser=") .Qpyb(txnh.User) .S(" description=") .Qpyb(txnh.Description)
buf .S("\nuser=") .Qpyb(txnh.User) .S(" description=") .Qpyb(txnh.Description)
// NOTE in zodb/py .length is len - 8, in zodb/go - whole txn record length
xbuf .S(" length=") .D64(txnh.Len - 8)
xbuf .S(" offset=") .D64(txnh.Pos) .S(" (+") .D64(txnh.HeaderLen()) .S(")\n\n")
buf .S(" length=") .D64(txnh.Len - 8)
buf .S(" offset=") .D64(txnh.Pos) .S(" (+") .D64(txnh.HeaderLen()) .S(")\n\n")
_, err = w.Write(xbuf.Bytes())
_, err = w.Write(buf.Bytes())
if err != nil {
break
}
......
......@@ -24,9 +24,9 @@
//
// xfmt analog would be
//
// xbuf := xfmt.Buffer{}
// xbuf .S("hello ") .Q("world") .C(' ') .D(1) .C(' ') .Xb([]byte("data"))
// s := xbuf.Bytes()
// buf := xfmt.Buffer{}
// buf .S("hello ") .Q("world") .C(' ') .D(1) .C(' ') .Xb([]byte("data"))
// s := buf.Bytes()
//
// xfmt.Buffer can be reused several times via Buffer.Reset() .
package xfmt
......
......@@ -52,7 +52,7 @@ type dumper struct {
afterFirst bool // true after first transaction has been dumped
xbuf xfmt.Buffer // reusable data buffer for formatting
buf xfmt.Buffer // reusable data buffer for formatting
}
var _LF = []byte{'\n'}
......@@ -60,31 +60,31 @@ var _LF = []byte{'\n'}
// DumpData dumps one data record
func (d *dumper) DumpData(datai *zodb.StorageRecordInformation) error {
xbuf := &d.xbuf
xbuf.Reset()
buf := &d.buf
buf.Reset()
xbuf .S("obj ") .V(&datai.Oid) .Cb(' ')
buf .S("obj ") .V(&datai.Oid) .Cb(' ')
writeData := false
switch {
case datai.Data == nil:
xbuf.S("delete")
buf .S("delete")
case datai.Tid != datai.DataTid:
xbuf .S("from ") .V(&datai.DataTid)
buf .S("from ") .V(&datai.DataTid)
default:
dataSha1 := sha1.Sum(datai.Data)
xbuf .D(len(datai.Data)) .S(" sha1:") .Xb(dataSha1[:])
buf .D(len(datai.Data)) .S(" sha1:") .Xb(dataSha1[:])
writeData = true
}
xbuf .Cb('\n')
buf .Cb('\n')
// TODO use writev(data, "\n") via net.Buffers (it is already available)
_, err := d.W.Write(xbuf.Bytes())
_, err := d.W.Write(buf.Bytes())
if err != nil {
goto out
}
......
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