2020-11-24 14:32:21 +00:00
|
|
|
package blobstor
|
|
|
|
|
|
|
|
import (
|
2021-05-18 08:12:51 +00:00
|
|
|
"errors"
|
|
|
|
|
2020-11-30 16:39:05 +00:00
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
2021-04-08 13:53:25 +00:00
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/fstree"
|
2021-09-06 14:28:07 +00:00
|
|
|
storagelog "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/internal/log"
|
2020-11-24 14:32:21 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// DeleteBigPrm groups the parameters of DeleteBig operation.
|
|
|
|
type DeleteBigPrm struct {
|
|
|
|
address
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeleteBigRes groups resulting values of DeleteBig operation.
|
|
|
|
type DeleteBigRes struct{}
|
|
|
|
|
|
|
|
// DeleteBig removes object from shallow dir of BLOB storage.
|
|
|
|
//
|
|
|
|
// Returns any error encountered that did not allow
|
|
|
|
// to completely remove the object.
|
|
|
|
//
|
2020-11-30 16:39:05 +00:00
|
|
|
// Returns ErrNotFound if there is no object to delete.
|
2020-11-24 14:32:21 +00:00
|
|
|
func (b *BlobStor) DeleteBig(prm *DeleteBigPrm) (*DeleteBigRes, error) {
|
2021-04-08 13:53:25 +00:00
|
|
|
err := b.fsTree.Delete(prm.addr)
|
|
|
|
if errors.Is(err, fstree.ErrFileNotFound) {
|
2020-11-30 16:39:05 +00:00
|
|
|
err = object.ErrNotFound
|
2020-11-24 14:32:21 +00:00
|
|
|
}
|
|
|
|
|
2021-09-06 14:28:07 +00:00
|
|
|
if err == nil {
|
|
|
|
storagelog.Write(b.log, storagelog.AddressField(prm.addr), storagelog.OpField("fstree DELETE"))
|
|
|
|
}
|
|
|
|
|
2020-11-24 14:32:21 +00:00
|
|
|
return nil, err
|
|
|
|
}
|