| 31 | } |
| 32 | |
| 33 | func (sys *System) Commit(ctx context.Context, txh blobcache.Handle) error { |
| 34 | logctx.Info(ctx, "begin", zap.String("method", "Commit"), zap.Stringer("oid", txh.OID)) |
| 35 | defer logctx.Info(ctx, "done", zap.String("method", "Commit"), zap.Stringer("oid", txh.OID)) |
| 36 | tx, err := sys.resolveTx(txh, true, 0) |
| 37 | if err != nil { |
| 38 | return err |
| 39 | } |
| 40 | if p := tx.backend.Params(); !p.Modify { |
| 41 | return blobcache.ErrTxReadOnly{Tx: txh.OID, Op: "COMMIT"} |
| 42 | } |
| 43 | if err := tx.backend.Commit(ctx); err != nil { |
| 44 | return setErrTxOID(err, txh.OID) |
| 45 | } |
| 46 | sys.mu.Lock() |
| 47 | sys.handles.Drop(txh) |
| 48 | sys.mu.Unlock() |
| 49 | sys.hub.Publish(ctx, tx.volume.info.ID, tx.volume) |
| 50 | return nil |
| 51 | } |
| 52 | |
| 53 | func (sys *System) Abort(ctx context.Context, txh blobcache.Handle) error { |
| 54 | logctx.Info(ctx, "begin", zap.String("method", "Abort"), zap.Stringer("oid", txh.OID)) |