2020-11-24 14:32:21 +00:00
|
|
|
package blobstor
|
|
|
|
|
|
|
|
import (
|
2021-05-18 08:12:51 +00:00
|
|
|
"errors"
|
|
|
|
|
2022-07-06 11:59:35 +00:00
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/common"
|
2021-09-06 14:28:07 +00:00
|
|
|
storagelog "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/internal/log"
|
2022-03-17 08:03:58 +00:00
|
|
|
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
|
2022-07-08 11:33:49 +00:00
|
|
|
"go.uber.org/zap"
|
2020-11-24 14:32:21 +00:00
|
|
|
)
|
|
|
|
|
2022-07-06 12:39:35 +00:00
|
|
|
func (b *BlobStor) Delete(prm common.DeletePrm) (common.DeleteRes, error) {
|
2022-07-06 14:09:50 +00:00
|
|
|
if prm.StorageID == nil {
|
2022-07-08 11:33:49 +00:00
|
|
|
for i := range b.storage {
|
|
|
|
res, err := b.storage[i].Storage.Delete(prm)
|
|
|
|
if err == nil || !errors.As(err, new(apistatus.ObjectNotFound)) {
|
|
|
|
if err == nil {
|
|
|
|
storagelog.Write(b.log,
|
|
|
|
storagelog.AddressField(prm.Address),
|
|
|
|
storagelog.OpField("DELETE"),
|
|
|
|
zap.String("type", b.storage[i].Storage.Type()),
|
|
|
|
zap.String("storage ID", string(prm.StorageID)))
|
|
|
|
}
|
|
|
|
return res, err
|
|
|
|
}
|
2022-07-06 12:39:35 +00:00
|
|
|
}
|
|
|
|
}
|
2022-07-06 14:09:50 +00:00
|
|
|
if len(prm.StorageID) == 0 {
|
2022-07-11 12:34:17 +00:00
|
|
|
return b.storage[len(b.storage)-1].Storage.Delete(prm)
|
2022-07-06 12:39:35 +00:00
|
|
|
}
|
2022-07-08 11:33:49 +00:00
|
|
|
return b.storage[0].Storage.Delete(prm)
|
2022-07-05 13:47:39 +00:00
|
|
|
}
|