forked from TrueCloudLab/frostfs-s3-gw
[#195] Fix object deletion
Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
parent
4a67e4b311
commit
e0b8bc6cd6
2 changed files with 16 additions and 9 deletions
|
@ -4,6 +4,7 @@ import (
|
|||
"encoding/xml"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/nspcc-dev/neofs-s3-gw/api"
|
||||
"github.com/nspcc-dev/neofs-s3-gw/api/errors"
|
||||
|
@ -70,6 +71,10 @@ func (h *handler) DeleteObjectHandler(w http.ResponseWriter, r *http.Request) {
|
|||
err = deletedObject.Error
|
||||
}
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "object is locked") {
|
||||
h.logAndSendError(w, "object is locked", reqInfo, errors.GetAPIError(errors.ErrAccessDenied))
|
||||
return
|
||||
}
|
||||
h.log.Error("could not delete object",
|
||||
zap.String("request_id", reqInfo.RequestID),
|
||||
zap.String("bucket_name", reqInfo.BucketName),
|
||||
|
|
|
@ -310,6 +310,8 @@ func (n *layer) handleLockTick(ctx context.Context, msg *nats.Msg) error {
|
|||
return fmt.Errorf("invalid msg, address expected: %w", err)
|
||||
}
|
||||
|
||||
n.log.Debug("handling lock tick", zap.String("address", string(msg.Data)))
|
||||
|
||||
// todo clear cache
|
||||
// and make sure having right access
|
||||
return n.objectDelete(ctx, addr.ContainerID(), addr.ObjectID())
|
||||
|
@ -646,15 +648,6 @@ func (n *layer) deleteObject(ctx context.Context, bkt *data.BucketInfo, obj *Ver
|
|||
p.Header[VersionsDeleteMarkAttr] = DelMarkFullObject
|
||||
}
|
||||
|
||||
objInfo, err := n.objectPut(ctx, bkt, p)
|
||||
if err != nil {
|
||||
obj.Error = err
|
||||
return obj
|
||||
}
|
||||
if len(obj.VersionID) == 0 {
|
||||
obj.DeleteMarkVersion = objInfo.Version()
|
||||
}
|
||||
|
||||
for _, id := range ids {
|
||||
if err = n.objectDelete(ctx, bkt.CID, id); err != nil {
|
||||
obj.Error = err
|
||||
|
@ -667,6 +660,15 @@ func (n *layer) deleteObject(ctx context.Context, bkt *data.BucketInfo, obj *Ver
|
|||
}
|
||||
n.listsCache.CleanCacheEntriesContainingObject(obj.Name, bkt.CID)
|
||||
|
||||
objInfo, err := n.objectPut(ctx, bkt, p)
|
||||
if err != nil {
|
||||
obj.Error = err
|
||||
return obj
|
||||
}
|
||||
if len(obj.VersionID) == 0 {
|
||||
obj.DeleteMarkVersion = objInfo.Version()
|
||||
}
|
||||
|
||||
return obj
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue