Commit cc960283 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent a3cb9f32
......@@ -49,7 +49,7 @@ type Storage struct {
// Close implements zodb.IStorageDriver .
func (ovl *Storage) Close() error {
func (ovl *Storage) Close() error { // XXX ovl -> d ?
// XXX errctx?
err1 := ovl.δ.Close()
......@@ -76,13 +76,17 @@ func (ovl *Storage) Sync(ctx context.Context) (head zodb.Tid, _ error) {
}
// Load implements zodb.IStorageDriver .
func (ovl *Storage) Load(ctx context.Context, xid zodb.Xid) (*mem.Buf, zodb.Tid, error) {
// XXX errctx?
func (ovl *Storage) Load(ctx context.Context, xid zodb.Xid) (_ *mem.Buf, _ zodb.Tid, err error) {
defer func() {
if err != nil {
err = &zodb.OpError{URL: ovl.URL(), Op: "load", Args: xid, Err: err}
}
}()
data, serial, err := ovl.δ.Load(ctx, xid)
if data != nil {
if err == nil {
// object data is present in δ
return data, serial, err
return data, serial, nil
}
useBase := false
......@@ -92,7 +96,7 @@ func (ovl *Storage) Load(ctx context.Context, xid zodb.Xid) (*mem.Buf, zodb.Tid,
case errors.As(err, &eNoData):
if eNoData.DeletedAt != 0 {
// object deleted in δ -> whiteout
return data, serial, err
return data, serial, eNoData
} else {
// object not created in δ
useBase = true
......@@ -109,6 +113,17 @@ func (ovl *Storage) Load(ctx context.Context, xid zodb.Xid) (*mem.Buf, zodb.Tid,
// XXX cap .at in xid to base.At0 ? (and convert back on error return)
data, serial, err = ovl.base.Load(ctx, xid)
if err == nil {
return data, serial, nil
}
switch {
case errors.As(err, &eNoData):
err = eNoData
case errors.As(err, &eNoObject):
err = eNoObject
}
return data, serial, err
}
......
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