diff --git a/pkg/storage/utils/decomposedfs/decomposedfs.go b/pkg/storage/utils/decomposedfs/decomposedfs.go index 4803cd2d9f4..feb5ac87fca 100644 --- a/pkg/storage/utils/decomposedfs/decomposedfs.go +++ b/pkg/storage/utils/decomposedfs/decomposedfs.go @@ -146,14 +146,12 @@ func (fs *Decomposedfs) Shutdown(ctx context.Context) error { // TODO Document in the cs3 should we return quota or free space? func (fs *Decomposedfs) GetQuota(ctx context.Context, ref *provider.Reference) (total uint64, inUse uint64, err error) { var n *node.Node - if ref != nil { - if n, err = fs.lu.NodeFromResource(ctx, ref); err != nil { - return 0, 0, err - } - } else { - if n, err = fs.lu.RootNode(ctx); err != nil { - return 0, 0, err - } + if ref == nil { + err = errtypes.BadRequest("no space given") + return 0, 0, err + } + if n, err = fs.lu.NodeFromResource(ctx, ref); err != nil { + return 0, 0, err } if !n.Exists { diff --git a/pkg/storage/utils/decomposedfs/lookup/lookup.go b/pkg/storage/utils/decomposedfs/lookup/lookup.go index 6fa1488a749..1ed4482ba82 100644 --- a/pkg/storage/utils/decomposedfs/lookup/lookup.go +++ b/pkg/storage/utils/decomposedfs/lookup/lookup.go @@ -127,13 +127,6 @@ func (lu *Lookup) Path(ctx context.Context, n *node.Node) (p string, err error) return } -// RootNode returns the root node of the storage -func (lu *Lookup) RootNode(ctx context.Context) (*node.Node, error) { - n := node.New(node.NoSpaceID, node.RootID, "", "", 0, "", nil, lu) - n.Exists = true - return n, nil -} - // WalkPath calls n.Child(segment) on every path segment in p starting at the node r. // If a function f is given it will be executed for every segment node, but not the root node r. // If followReferences is given the current visited reference node is replaced by the referenced node. diff --git a/pkg/storage/utils/decomposedfs/node/locks_test.go b/pkg/storage/utils/decomposedfs/node/locks_test.go index d86c677ad29..08ca26f87c8 100644 --- a/pkg/storage/utils/decomposedfs/node/locks_test.go +++ b/pkg/storage/utils/decomposedfs/node/locks_test.go @@ -68,8 +68,8 @@ var _ = Describe("Node locks", func() { User: env.Owner.Id, LockId: uuid.New().String(), } - n = node.New("tobelockedid", "", "tobelocked", 10, "", env.Owner.Id, env.Lookup) - n2 = node.New("neverlockedid", "", "neverlocked", 10, "", env.Owner.Id, env.Lookup) + n = node.New("spaceid", "tobelockedid", "", "tobelocked", 10, "", env.Owner.Id, env.Lookup) + n2 = node.New("spaceid", "neverlockedid", "", "neverlocked", 10, "", env.Owner.Id, env.Lookup) }) AfterEach(func() { diff --git a/pkg/storage/utils/decomposedfs/node/node.go b/pkg/storage/utils/decomposedfs/node/node.go index 031075a5479..40395ca1d56 100644 --- a/pkg/storage/utils/decomposedfs/node/node.go +++ b/pkg/storage/utils/decomposedfs/node/node.go @@ -87,8 +87,6 @@ type Node struct { // PathLookup defines the interface for the lookup component type PathLookup interface { - RootNode(ctx context.Context) (node *Node, err error) - InternalRoot() string InternalPath(spaceID, nodeID string) string Path(ctx context.Context, n *Node) (path string, err error) @@ -660,19 +658,8 @@ 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 { - root, err := n.lu.RootNode(ctx) - if err == nil { - quotaPath = root.InternalPath() - } else { - sublog.Debug().Err(err).Msg("error determining the space root node for quota") - } - } else { - quotaPath = n.SpaceRoot.InternalPath() - } - if quotaPath != "" { - readQuotaIntoOpaque(ctx, quotaPath, ri) + if n.SpaceRoot != nil && n.SpaceRoot.InternalPath() != "" { + readQuotaIntoOpaque(ctx, n.SpaceRoot.InternalPath(), ri) } } diff --git a/pkg/storage/utils/decomposedfs/node/permissions.go b/pkg/storage/utils/decomposedfs/node/permissions.go index ec0f8c8789c..1d089f71dc7 100644 --- a/pkg/storage/utils/decomposedfs/node/permissions.go +++ b/pkg/storage/utils/decomposedfs/node/permissions.go @@ -123,10 +123,8 @@ func (p *Permissions) AssemblePermissions(ctx context.Context, n *Node) (ap prov return OwnerPermissions(), nil } // determine root - var rn *Node - if rn, err = p.lu.RootNode(ctx); err != nil { - return NoPermissions(), err - } + + rn := n.SpaceRoot cn := n diff --git a/pkg/storage/utils/decomposedfs/tree/tree.go b/pkg/storage/utils/decomposedfs/tree/tree.go index b9744e5278f..2ca2f6950c5 100644 --- a/pkg/storage/utils/decomposedfs/tree/tree.go +++ b/pkg/storage/utils/decomposedfs/tree/tree.go @@ -60,7 +60,6 @@ type Blobstore interface { type PathLookup interface { NodeFromResource(ctx context.Context, ref *provider.Reference) (*node.Node, error) NodeFromID(ctx context.Context, id *provider.ResourceId) (n *node.Node, err error) - RootNode(ctx context.Context) (node *node.Node, err error) InternalRoot() string InternalPath(spaceID, nodeID string) string @@ -609,14 +608,7 @@ func (t *Tree) Propagate(ctx context.Context, n *node.Node) (err error) { // is propagation enabled for the parent node? - var root *node.Node - if n.SpaceRoot == nil { - if root, err = t.lookup.RootNode(ctx); err != nil { - return - } - } else { - root = n.SpaceRoot - } + root := n.SpaceRoot // use a sync time and don't rely on the mtime of the current node, as the stat might not change when a rename happened too quickly sTime := time.Now().UTC() diff --git a/pkg/storage/utils/decomposedfs/upload_test.go b/pkg/storage/utils/decomposedfs/upload_test.go index 074cd68e96a..87a11ff54c1 100644 --- a/pkg/storage/utils/decomposedfs/upload_test.go +++ b/pkg/storage/utils/decomposedfs/upload_test.go @@ -32,6 +32,7 @@ import ( "github.com/cs3org/reva/pkg/errtypes" "github.com/cs3org/reva/pkg/storage" "github.com/cs3org/reva/pkg/storage/utils/decomposedfs" + "github.com/cs3org/reva/pkg/storage/utils/decomposedfs/lookup" "github.com/cs3org/reva/pkg/storage/utils/decomposedfs/mocks" "github.com/cs3org/reva/pkg/storage/utils/decomposedfs/node" "github.com/cs3org/reva/pkg/storage/utils/decomposedfs/options" @@ -56,7 +57,7 @@ var _ = Describe("File uploads", func() { spaceID string o *options.Options - lookup *decomposedfs.Lookup + lookup *lookup.Lookup permissions *mocks.PermissionsChecker bs *treemocks.Blobstore ) @@ -94,7 +95,7 @@ var _ = Describe("File uploads", func() { "root": tmpRoot, }) Expect(err).ToNot(HaveOccurred()) - lookup = &decomposedfs.Lookup{Options: o} + lookup = &lookup.Lookup{Options: o} permissions = &mocks.PermissionsChecker{} bs = &treemocks.Blobstore{} })