[#233] Fix browsing
All checks were successful
/ DCO (pull_request) Successful in 39s
/ Vulncheck (pull_request) Successful in 59s
/ Builds (pull_request) Successful in 51s
/ OCI image (pull_request) Successful in 1m29s
/ Lint (pull_request) Successful in 2m27s
/ Tests (pull_request) Successful in 1m30s
/ Integration tests (pull_request) Successful in 6m10s
/ Vulncheck (push) Successful in 58s
/ Builds (push) Successful in 1m4s
/ OCI image (push) Successful in 1m28s
/ Lint (push) Successful in 2m13s
/ Tests (push) Successful in 1m11s
/ Integration tests (push) Successful in 5m56s
All checks were successful
/ DCO (pull_request) Successful in 39s
/ Vulncheck (pull_request) Successful in 59s
/ Builds (pull_request) Successful in 51s
/ OCI image (pull_request) Successful in 1m29s
/ Lint (pull_request) Successful in 2m27s
/ Tests (pull_request) Successful in 1m30s
/ Integration tests (pull_request) Successful in 6m10s
/ Vulncheck (push) Successful in 58s
/ Builds (push) Successful in 1m4s
/ OCI image (push) Successful in 1m28s
/ Lint (push) Successful in 2m13s
/ Tests (push) Successful in 1m11s
/ Integration tests (push) Successful in 5m56s
Simplify tree listing (we need only nodes in exactly the same parent level) Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
This commit is contained in:
parent
e579549b41
commit
dbb1bcad00
11 changed files with 302 additions and 151 deletions
|
@ -11,8 +11,8 @@ import (
|
|||
"git.frostfs.info/TrueCloudLab/frostfs-http-gw/internal/cache"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-http-gw/internal/data"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-http-gw/internal/handler/middleware"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-http-gw/internal/layer"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-http-gw/internal/logs"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-http-gw/tree"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-http-gw/utils"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/bearer"
|
||||
|
@ -173,7 +173,7 @@ type Handler struct {
|
|||
ownerID *user.ID
|
||||
config Config
|
||||
containerResolver ContainerResolver
|
||||
tree layer.TreeService
|
||||
tree *tree.Tree
|
||||
cache *cache.BucketCache
|
||||
workerPool *ants.Pool
|
||||
corsCnrID cid.ID
|
||||
|
@ -190,7 +190,7 @@ type AppParams struct {
|
|||
CORSCache *cache.CORSCache
|
||||
}
|
||||
|
||||
func New(params *AppParams, config Config, tree layer.TreeService, workerPool *ants.Pool) *Handler {
|
||||
func New(params *AppParams, config Config, tree *tree.Tree, workerPool *ants.Pool) *Handler {
|
||||
return &Handler{
|
||||
log: params.Logger,
|
||||
frostfs: params.FrostFS,
|
||||
|
@ -205,36 +205,6 @@ func New(params *AppParams, config Config, tree layer.TreeService, workerPool *a
|
|||
}
|
||||
}
|
||||
|
||||
// byNativeAddress is a wrapper for function (e.g. request.headObject, request.receiveFile) that
|
||||
// prepares request and object address to it.
|
||||
func (h *Handler) byNativeAddress(ctx context.Context, req *fasthttp.RequestCtx, cnrID cid.ID, objID oid.ID, handler func(context.Context, *fasthttp.RequestCtx, oid.Address)) {
|
||||
ctx, span := tracing.StartSpanFromContext(ctx, "handler.byNativeAddress")
|
||||
defer span.End()
|
||||
|
||||
addr := newAddress(cnrID, objID)
|
||||
handler(ctx, req, addr)
|
||||
}
|
||||
|
||||
// byS3Path is a wrapper for function (e.g. request.headObject, request.receiveFile) that
|
||||
// resolves object address from S3-like path <bucket name>/<object key>.
|
||||
func (h *Handler) byS3Path(ctx context.Context, req *fasthttp.RequestCtx, bktInfo *data.BucketInfo, path string, handler func(context.Context, *fasthttp.RequestCtx, oid.Address)) {
|
||||
ctx, span := tracing.StartSpanFromContext(ctx, "handler.byS3Path")
|
||||
defer span.End()
|
||||
|
||||
foundOID, err := h.tree.GetLatestVersion(ctx, &bktInfo.CID, path)
|
||||
if err != nil {
|
||||
h.logAndSendError(ctx, req, logs.FailedToGetLatestVersionOfObject, err, zap.String("path", path))
|
||||
return
|
||||
}
|
||||
if foundOID.IsDeleteMarker {
|
||||
h.logAndSendError(ctx, req, logs.ObjectWasDeleted, ErrObjectNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
addr := newAddress(bktInfo.CID, foundOID.OID)
|
||||
handler(ctx, req, addr)
|
||||
}
|
||||
|
||||
// byAttribute is a wrapper similar to byNativeAddress.
|
||||
func (h *Handler) byAttribute(ctx context.Context, req *fasthttp.RequestCtx, handler func(context.Context, *fasthttp.RequestCtx, oid.Address)) {
|
||||
cidParam, _ := req.UserValue("cid").(string)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue