diff --git a/pkg/storage/utils/decomposedfs/node/node.go b/pkg/storage/utils/decomposedfs/node/node.go index bfac1410d7e..bb6497ab2ac 100644 --- a/pkg/storage/utils/decomposedfs/node/node.go +++ b/pkg/storage/utils/decomposedfs/node/node.go @@ -611,16 +611,19 @@ func (n *Node) AsResourceInfo(ctx context.Context, rp *provider.ResourcePermissi // quota if _, ok := mdKeysMap[QuotaKey]; (nodeType == provider.ResourceType_RESOURCE_TYPE_CONTAINER) && returnAllKeys || ok { var quotaPath string - if n.SpaceRoot != nil { - quotaPath = n.SpaceRoot.InternalPath() - } else { + if n.SpaceRoot == nil { root, err := n.lu.HomeOrRootNode(ctx) - if err != nil { - sublog.Error().Err(err).Msg("error determining the space root node for quota") + if err == nil { + quotaPath = root.InternalPath() + } else { + sublog.Debug().Err(err).Msg("error determining the space root node for quota") } - quotaPath = root.InternalPath() + } else { + quotaPath = n.SpaceRoot.InternalPath() + } + if quotaPath != "" { + readQuotaIntoOpaque(ctx, quotaPath, ri) } - readQuotaIntoOpaque(ctx, quotaPath, ri) } // only read the requested metadata attributes diff --git a/pkg/storage/utils/decomposedfs/upload.go b/pkg/storage/utils/decomposedfs/upload.go index 42be84e4ec3..e8011532f63 100644 --- a/pkg/storage/utils/decomposedfs/upload.go +++ b/pkg/storage/utils/decomposedfs/upload.go @@ -132,6 +132,9 @@ func (fs *Decomposedfs) InitiateUpload(ctx context.Context, ref *provider.Refere "dir": filepath.Dir(relative), }, Size: uploadLength, + Storage: map[string]string{ + "SpaceRoot": n.SpaceRoot.ID, + }, } if metadata != nil { @@ -250,16 +253,23 @@ func (fs *Decomposedfs) NewUpload(ctx context.Context, info tusd.FileInfo) (uplo if err != nil { return nil, errors.Wrap(err, "Decomposedfs: error determining owner") } + var spaceRoot string + if info.Storage != nil { + if spaceRoot, ok = info.Storage["SpaceRoot"]; !ok { + spaceRoot = n.SpaceRoot.ID + } + } else { + spaceRoot = n.SpaceRoot.ID + } info.Storage = map[string]string{ - // Todo: add storage space root "Type": "OCISStore", "BinPath": binPath, "NodeId": n.ID, "NodeParentId": n.ParentID, "NodeName": n.Name, - "SpaceRoot": n.SpaceRoot.ID, + "SpaceRoot": spaceRoot, "Idp": usr.Id.Idp, "UserId": usr.Id.OpaqueId, @@ -739,14 +749,13 @@ func (upload *fileUpload) ConcatUploads(ctx context.Context, uploads []tusd.Uplo } func checkQuota(ctx context.Context, fs *Decomposedfs, spaceRoot *node.Node, fileSize uint64) (quotaSufficient bool, err error) { - req := &provider.GetQuotaRequest{ + total, inUse, err := fs.GetQuota(ctx, &provider.GetQuotaRequest{ Ref: &provider.Reference{ ResourceId: &provider.ResourceId{ OpaqueId: spaceRoot.ID, }, }, - } - total, inUse, err := fs.GetQuota(ctx, req) + }) if err != nil { switch err.(type) { case errtypes.NotFound: