diff --git a/api/handler/delete.go b/api/handler/delete.go index 281bbd115..493e4b5a0 100644 --- a/api/handler/delete.go +++ b/api/handler/delete.go @@ -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), diff --git a/api/layer/layer.go b/api/layer/layer.go index 44c0602a3..003476540 100644 --- a/api/layer/layer.go +++ b/api/layer/layer.go @@ -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 }