2020-11-24 14:32:21 +00:00
|
|
|
package blobstor
|
|
|
|
|
|
|
|
import (
|
2021-05-18 08:12:51 +00:00
|
|
|
"errors"
|
|
|
|
|
2022-12-23 17:35:35 +00:00
|
|
|
"github.com/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common"
|
|
|
|
apistatus "github.com/TrueCloudLab/frostfs-sdk-go/client/status"
|
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-11-15 12:33:48 +00:00
|
|
|
b.modeMtx.RLock()
|
|
|
|
defer b.modeMtx.RUnlock()
|
|
|
|
|
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 {
|
2022-10-21 17:51:31 +00:00
|
|
|
logOp(b.log, deleteOp, prm.Address, b.storage[i].Storage.Type(), prm.StorageID)
|
2022-07-08 11:33:49 +00:00
|
|
|
}
|
|
|
|
return res, err
|
|
|
|
}
|
2022-07-06 12:39:35 +00:00
|
|
|
}
|
|
|
|
}
|
2022-10-21 17:51:31 +00:00
|
|
|
|
|
|
|
var st common.Storage
|
|
|
|
|
2022-07-06 14:09:50 +00:00
|
|
|
if len(prm.StorageID) == 0 {
|
2022-10-21 17:51:31 +00:00
|
|
|
st = b.storage[len(b.storage)-1].Storage
|
|
|
|
} else {
|
|
|
|
st = b.storage[0].Storage
|
2022-07-06 12:39:35 +00:00
|
|
|
}
|
2022-10-21 17:51:31 +00:00
|
|
|
|
|
|
|
res, err := st.Delete(prm)
|
|
|
|
if err == nil {
|
|
|
|
logOp(b.log, deleteOp, prm.Address, st.Type(), prm.StorageID)
|
|
|
|
}
|
|
|
|
|
|
|
|
return res, err
|
2022-07-05 13:47:39 +00:00
|
|
|
}
|