Commit fd9e0bfe authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent d972be0f
...@@ -22,6 +22,7 @@ import ( ...@@ -22,6 +22,7 @@ import (
"encoding/binary" "encoding/binary"
"fmt" "fmt"
"io" "io"
"math/big"
"net" "net"
"os" "os"
"strconv" "strconv"
...@@ -68,7 +69,7 @@ const ( ...@@ -68,7 +69,7 @@ const (
// IndexSaveError is the error type returned by index save routines // IndexSaveError is the error type returned by index save routines
type IndexSaveError struct { type IndexSaveError struct {
Err error // error that occured during the operation Err error // error that occurred during the operation
} }
func (e *IndexSaveError) Error() string { func (e *IndexSaveError) Error() string {
...@@ -190,6 +191,20 @@ func (e *IndexLoadError) Error() string { ...@@ -190,6 +191,20 @@ func (e *IndexLoadError) Error() string {
return s return s
} }
// xint64 tries to convert unpickled value to int64
func xint64(xv interface{}) (v int64, ok bool) {
switch v := xv.(type) {
case int64:
return v, true
case *big.Int:
if v.IsInt64() {
return v.Int64(), true
}
}
return 0, false
}
// LoadIndex loads index from a reader // LoadIndex loads index from a reader
func LoadIndex(r io.Reader) (topPos int64, fsi *fsIndex, err error) { func LoadIndex(r io.Reader) (topPos int64, fsi *fsIndex, err error) {
var picklePos int64 var picklePos int64
...@@ -207,9 +222,9 @@ func LoadIndex(r io.Reader) (topPos int64, fsi *fsIndex, err error) { ...@@ -207,9 +222,9 @@ func LoadIndex(r io.Reader) (topPos int64, fsi *fsIndex, err error) {
if err != nil { if err != nil {
goto out goto out
} }
topPos, ok = xtopPos.(int64) topPos, ok = xint64(xtopPos)
if !ok { if !ok {
err = fmt.Errorf("topPos is %T (expected int64)", xtopPos) err = fmt.Errorf("topPos is %T:%v (expected int64)", xtopPos, xtopPos)
goto out goto out
} }
...@@ -366,7 +381,7 @@ func (r *BufReader) InputOffset() int64 { ...@@ -366,7 +381,7 @@ func (r *BufReader) InputOffset() int64 {
} }
// IOName returns a "filename" associated with io.Reader, io.Writer, net.Conn, ... // IOName returns a "filename" associated with io.Reader, io.Writer, net.Conn, ...
// if name cannot be deterined - "" is returned. // if name cannot be determined - "" is returned.
func IOName(f interface {}) string { func IOName(f interface {}) string {
switch f := f.(type) { switch f := f.(type) {
case *os.File: case *os.File:
......
...@@ -103,6 +103,8 @@ out: ...@@ -103,6 +103,8 @@ out:
// DumpTxn dumps one transaction record // DumpTxn dumps one transaction record
func (d *dumper) DumpTxn(txni *zodb.TxnInfo, dataIter zodb.IStorageRecordIterator) error { func (d *dumper) DumpTxn(txni *zodb.TxnInfo, dataIter zodb.IStorageRecordIterator) error {
var datai *zodb.StorageRecordInformation
// LF in-between txn records // LF in-between txn records
vskip := "\n" vskip := "\n"
if !d.afterFirst { if !d.afterFirst {
...@@ -118,7 +120,7 @@ func (d *dumper) DumpTxn(txni *zodb.TxnInfo, dataIter zodb.IStorageRecordIterato ...@@ -118,7 +120,7 @@ func (d *dumper) DumpTxn(txni *zodb.TxnInfo, dataIter zodb.IStorageRecordIterato
// data records // data records
for { for {
datai, err := dataIter.NextData() datai, err = dataIter.NextData()
if err != nil { if err != nil {
if err == io.EOF { if err == io.EOF {
err = nil // XXX -> okEOF ? err = nil // XXX -> okEOF ?
......
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