[#70] Support bucket/container caching

Mainly it was added because
we need to know if TZ hashing is disabled or not for container

Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
This commit is contained in:
Denis Kirillov 2023-10-04 14:50:37 +03:00 committed by Alexey Vanin
parent 8bc246f8f9
commit 9a5a2239bd
17 changed files with 283 additions and 48 deletions

View file

@ -57,10 +57,9 @@ func (h *Handler) Upload(req *fasthttp.RequestCtx) {
ctx := utils.GetContextFromRequest(req)
idCnr, err := h.getContainerID(ctx, scid)
bktInfo, err := h.getBucketInfo(ctx, scid, log)
if err != nil {
log.Error(logs.WrongContainerID, zap.Error(err))
response.Error(req, "wrong container id", fasthttp.StatusBadRequest)
logAndSendBucketError(req, log, err)
return
}
@ -129,7 +128,7 @@ func (h *Handler) Upload(req *fasthttp.RequestCtx) {
}
obj := object.New()
obj.SetContainerID(*idCnr)
obj.SetContainerID(bktInfo.CID)
obj.SetOwnerID(h.ownerID)
obj.SetAttributes(attributes...)
@ -138,6 +137,7 @@ func (h *Handler) Upload(req *fasthttp.RequestCtx) {
prm.SetPayload(file)
prm.SetClientCut(h.config.ClientCut())
prm.SetBufferMaxSize(h.config.BufferMaxSizeForPut())
prm.WithoutHomomorphicHash(bktInfo.HomomorphicHashDisabled)
bt := h.fetchBearerToken(ctx)
if bt != nil {
@ -150,7 +150,7 @@ func (h *Handler) Upload(req *fasthttp.RequestCtx) {
}
addr.SetObject(idObj)
addr.SetContainer(*idCnr)
addr.SetContainer(bktInfo.CID)
// Try to return the response, otherwise, if something went wrong, throw an error.
if err = newPutResponse(addr).encode(req); err != nil {