Commit 6108dadf authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 6320d7fc
...@@ -148,21 +148,21 @@ func bug(e xerr, format string, a ...interface{}) { ...@@ -148,21 +148,21 @@ func bug(e xerr, format string, a ...interface{}) {
} }
// noEOF returns err, but changes io.EOF -> io.ErrUnexpectedEOF // // noEOF returns err, but changes io.EOF -> io.ErrUnexpectedEOF
func noEOF(err error) error { // func NoEOF(err error) error {
if err == io.EOF { // if err == io.EOF {
err = io.ErrUnexpectedEOF // err = io.ErrUnexpectedEOF
} // }
return err // return err
} // }
//
// okEOF returns err, but changes io.EOF -> nil // // okEOF returns err, but changes io.EOF -> nil
func okEOF(err error) error { // func okEOF(err error) error {
if err == io.EOF { // if err == io.EOF {
err = nil // err = nil
} // }
return err // return err
} // }
// --- Transaction record --- // --- Transaction record ---
...@@ -268,7 +268,7 @@ func (txnh *TxnHeader) Load(r io.ReaderAt /* *os.File */, pos int64, flags TxnLo ...@@ -268,7 +268,7 @@ func (txnh *TxnHeader) Load(r io.ReaderAt /* *os.File */, pos int64, flags TxnLo
// EOF after txn header is not good - because at least // EOF after txn header is not good - because at least
// redundant length should be also there // redundant length should be also there
return txnh.err("read", noEOF(err)) return txnh.err("read", xio.NoEOF(err))
} }
txnh.Tid = zodb.Tid(binary.BigEndian.Uint64(work[8+0:])) txnh.Tid = zodb.Tid(binary.BigEndian.Uint64(work[8+0:]))
...@@ -327,7 +327,7 @@ func (txnh *TxnHeader) loadStrings(r io.ReaderAt /* *os.File */) error { ...@@ -327,7 +327,7 @@ func (txnh *TxnHeader) loadStrings(r io.ReaderAt /* *os.File */) error {
// we rely on Load leaving len(workMem) = sum of all strings length ... // we rely on Load leaving len(workMem) = sum of all strings length ...
_, err := r.ReadAt(txnh.workMem, txnh.Pos + TxnHeaderFixSize) _, err := r.ReadAt(txnh.workMem, txnh.Pos + TxnHeaderFixSize)
if err != nil { if err != nil {
return txnh.err("read strings", noEOF(err)) return txnh.err("read strings", xio.noEOF(err))
} }
// ... and presetting x to point to appropriate places in .workMem . // ... and presetting x to point to appropriate places in .workMem .
...@@ -418,7 +418,7 @@ func (dh *DataHeader) load(r io.ReaderAt /* *os.File */, pos int64, tmpBuf *[Dat ...@@ -418,7 +418,7 @@ func (dh *DataHeader) load(r io.ReaderAt /* *os.File */, pos int64, tmpBuf *[Dat
_, err := r.ReadAt(tmpBuf[:], pos) _, err := r.ReadAt(tmpBuf[:], pos)
if err != nil { if err != nil {
return dh.err("read", noEOF(err)) return dh.err("read", xio.noEOF(err))
} }
// XXX also check oid.Valid() ? // XXX also check oid.Valid() ?
...@@ -518,7 +518,7 @@ func (dh *DataHeader) LoadBack(r io.ReaderAt /* *os.File */) error { ...@@ -518,7 +518,7 @@ func (dh *DataHeader) LoadBack(r io.ReaderAt /* *os.File */) error {
var xxx [8]byte // XXX escapes ? var xxx [8]byte // XXX escapes ?
_, err := r.ReadAt(xxx[:], dh.Pos + DataHeaderSize) _, err := r.ReadAt(xxx[:], dh.Pos + DataHeaderSize)
if err != nil { if err != nil {
return dh.err("read data", noEOF(err)) return dh.err("read data", xio.noEOF(err))
} }
backPos := int64(binary.BigEndian.Uint64(xxx[:])) backPos := int64(binary.BigEndian.Uint64(xxx[:]))
...@@ -627,7 +627,7 @@ func (dh *DataHeader) LoadData(r io.ReaderAt /* *os.File */, buf *[]byte) error ...@@ -627,7 +627,7 @@ func (dh *DataHeader) LoadData(r io.ReaderAt /* *os.File */, buf *[]byte) error
} }
_, err := r.ReadAt(*buf, dh.Pos + DataHeaderSize) _, err := r.ReadAt(*buf, dh.Pos + DataHeaderSize)
if err != nil { if err != nil {
return dh.err("read data", noEOF(err)) // XXX recheck return dh.err("read data", xio.noEOF(err)) // XXX recheck
} }
return nil return nil
...@@ -921,7 +921,7 @@ func (fs *FileStorage) Iterate(tidMin, tidMax zodb.Tid) zodb.IStorageIterator { ...@@ -921,7 +921,7 @@ func (fs *FileStorage) Iterate(tidMin, tidMax zodb.Tid) zodb.IStorageIterator {
for { for {
err = iter.NextTxn(LoadNoStrings) err = iter.NextTxn(LoadNoStrings)
if err != nil { if err != nil {
err = okEOF(err) err = xio.OkEOF(err)
break break
} }
} }
......
...@@ -40,6 +40,7 @@ import ( ...@@ -40,6 +40,7 @@ import (
"../../../zodb" "../../../zodb"
"lab.nexedi.com/kirr/go123/mem" "lab.nexedi.com/kirr/go123/mem"
"lab.nexedi.com/kirr/go123/xio"
) )
func zodbDump(w io.Writer, stor zodb.IStorage, tidMin, tidMax zodb.Tid, hashOnly bool) error { func zodbDump(w io.Writer, stor zodb.IStorage, tidMin, tidMax zodb.Tid, hashOnly bool) error {
...@@ -48,7 +49,7 @@ func zodbDump(w io.Writer, stor zodb.IStorage, tidMin, tidMax zodb.Tid, hashOnly ...@@ -48,7 +49,7 @@ func zodbDump(w io.Writer, stor zodb.IStorage, tidMin, tidMax zodb.Tid, hashOnly
for { for {
txni, dataIter, err := iter.NextTxn() txni, dataIter, err := iter.NextTxn()
if err != nil { if err != nil {
err = okEOF(err) err = xio.OkEOF(err)
break break
} }
...@@ -64,7 +65,7 @@ func zodbDump(w io.Writer, stor zodb.IStorage, tidMin, tidMax zodb.Tid, hashOnly ...@@ -64,7 +65,7 @@ func zodbDump(w io.Writer, stor zodb.IStorage, tidMin, tidMax zodb.Tid, hashOnly
for { for {
datai, err := dataIter.NextData() datai, err := dataIter.NextData()
if err != nil { if err != nil {
err = okEOF(err) err = xio.OkEOF(err)
break break
} }
...@@ -102,6 +103,8 @@ func zodbDump(w io.Writer, stor zodb.IStorage, tidMin, tidMax zodb.Tid, hashOnly ...@@ -102,6 +103,8 @@ func zodbDump(w io.Writer, stor zodb.IStorage, tidMin, tidMax zodb.Tid, hashOnly
} }
// XXX check err // XXX check err
return nil
} }
func usage() { func usage() {
......
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