[#544] internal/neofs: Prevent potential NPE-panic in DeleteContainer

Session token parameter of `NeoFS.DeleteContainer` method is optional
and can be `nil`.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2022-06-22 16:15:45 +03:00 committed by Alex Vanin
parent 028a152e04
commit 4fe833164e

View file

@ -207,9 +207,12 @@ func (x *NeoFS) ContainerEACL(ctx context.Context, id cid.ID) (*eacl.Table, erro
func (x *NeoFS) DeleteContainer(ctx context.Context, id cid.ID, token *session.Container) error { func (x *NeoFS) DeleteContainer(ctx context.Context, id cid.ID, token *session.Container) error {
var prm pool.PrmContainerDelete var prm pool.PrmContainerDelete
prm.SetContainerID(id) prm.SetContainerID(id)
prm.SetSessionToken(*token)
prm.SetWaitParams(x.await) prm.SetWaitParams(x.await)
if token != nil {
prm.SetSessionToken(*token)
}
err := x.pool.DeleteContainer(ctx, prm) err := x.pool.DeleteContainer(ctx, prm)
if err != nil { if err != nil {
return fmt.Errorf("delete container via connection pool: %w", err) return fmt.Errorf("delete container via connection pool: %w", err)