2020-11-24 14:32:21 +00:00
|
|
|
package blobstor
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
|
2020-11-30 16:39:05 +00:00
|
|
|
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
2020-11-24 14:32:21 +00:00
|
|
|
"github.com/pkg/errors"
|
|
|
|
)
|
|
|
|
|
|
|
|
// 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) {
|
|
|
|
err := b.fsTree.delete(prm.addr)
|
|
|
|
if errors.Is(err, errFileNotFound) {
|
2020-11-30 16:39:05 +00:00
|
|
|
err = object.ErrNotFound
|
2020-11-24 14:32:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2020-11-30 16:39:05 +00:00
|
|
|
func (t *fsTree) delete(addr *objectSDK.Address) error {
|
2020-11-25 11:18:54 +00:00
|
|
|
p, err := t.exists(addr)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2020-11-24 14:32:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return os.Remove(p)
|
|
|
|
}
|