Commit 113c3f7d authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent f2eb6a5b
......@@ -238,7 +238,7 @@ func (dh *DataHeader) Free() {
dhPool.Put(dh)
}
func (fs *FileStorage) Load(_ context.Context, xid zodb.Xid) (data *zodb.Buf, tid zodb.Tid, err error) {
func (fs *FileStorage) Load(_ context.Context, xid zodb.Xid) (buf *zodb.Buf, tid zodb.Tid, err error) {
// lookup in index position of oid data record within latest transaction who changed this oid
dataPos, ok := fs.index.Get(xid.Oid)
if !ok {
......@@ -283,17 +283,17 @@ func (fs *FileStorage) Load(_ context.Context, xid zodb.Xid) (data *zodb.Buf, ti
// be of first-found transaction
tid = dh.Tid
data, err = dh.LoadData(fs.file)
buf, err = dh.LoadData(fs.file)
if err != nil {
return nil, 0, &ErrXidLoad{xid, err}
}
if data == nil {
if buf.Data == nil {
// data was deleted
// XXX or allow this and return via data=nil ?
// XXX or allow this and return via buf.Data=nil ?
return nil, 0, &zodb.ErrXidMissing{Xid: xid}
}
return data, tid, nil
return buf, tid, nil
}
// --- ZODB-level iteration ---
......
......@@ -82,7 +82,12 @@ func checkLoad(t *testing.T, fs *FileStorage, xid zodb.Xid, expect oidLoadedOk)
if tid != expect.tid {
t.Errorf("load %v: returned tid unexpected: %v ; want: %v", xid, tid, expect.tid)
}
if !reflect.DeepEqual(buf.Data, expect.data) { // NOTE reflect to catch nil != ""
switch {
case buf == nil:
t.Errorf("load %v: returned buf = nil", xid)
case !reflect.DeepEqual(buf.Data, expect.data): // NOTE reflect to catch nil != ""
t.Errorf("load %v: different data:\nhave: %q\nwant: %q", xid, buf.Data, expect.data)
}
}
......
......@@ -675,7 +675,7 @@ func (dh *DataHeader) LoadData(r io.ReaderAt) (*zodb.Buf, error) {
err := dh.LoadBack(r)
if err != nil {
if err == io.EOF {
return nil, nil // deleted
return &zodb.Buf{Data: nil}, nil // deleted
}
return nil, err // XXX recheck
}
......
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