From 5a666db332228371ac93243d39297c2804e4f479 Mon Sep 17 00:00:00 2001 From: David Christofas Date: Wed, 12 Jan 2022 17:15:05 +0100 Subject: [PATCH] store nodes of a space inside of the space This is still work in progress. In this state the node_test.go run successfully. --- pkg/storage/utils/decomposedfs/node/node.go | 3 ++- pkg/storage/utils/decomposedfs/spaces.go | 6 +++--- pkg/storage/utils/decomposedfs/testhelpers/helpers.go | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pkg/storage/utils/decomposedfs/node/node.go b/pkg/storage/utils/decomposedfs/node/node.go index 1e8253aaeea..63118d13513 100644 --- a/pkg/storage/utils/decomposedfs/node/node.go +++ b/pkg/storage/utils/decomposedfs/node/node.go @@ -65,6 +65,7 @@ const ( NoSpaceID = "" // TrashIDDelimiter represents the characters used to separate the nodeid and the deletion time. TrashIDDelimiter = ".T." + NoSpaceID = "" ) // Node represents a node in the tree and provides methods to get a Parent or Child instance @@ -402,7 +403,7 @@ func (n *Node) ParentInternalPath() string { // LockFilePath returns the internal path of the lock file of the node func (n *Node) LockFilePath() string { - return n.lu.InternalPath(n.ID) + ".lock" + return n.InternalPath() + ".lock" } // CalculateEtag returns a hash of fileid + tmtime (or mtime) diff --git a/pkg/storage/utils/decomposedfs/spaces.go b/pkg/storage/utils/decomposedfs/spaces.go index 2fdde023301..02244d4bca0 100644 --- a/pkg/storage/utils/decomposedfs/spaces.go +++ b/pkg/storage/utils/decomposedfs/spaces.go @@ -342,7 +342,7 @@ func (fs *Decomposedfs) UpdateStorageSpace(ctx context.Context, req *provider.Up appctx.GetLogger(ctx).Error().Err(err).Str("match", matches[0]).Msg("could not read link, skipping") } - n, err := node.ReadNode(ctx, fs.lu, filepath.Base(target)) + n, err := node.ReadNode(ctx, fs.lu, spaceID, filepath.Base(target)) if err != nil { return nil, err } @@ -429,7 +429,7 @@ func (fs *Decomposedfs) DeleteStorageSpace(ctx context.Context, req *provider.De appctx.GetLogger(ctx).Error().Err(err).Str("match", matches[0]).Msg("could not read link, skipping") } - n, err := node.ReadNode(ctx, fs.lu, filepath.Base(target)) + n, err := node.ReadNode(ctx, fs.lu, spaceID, filepath.Base(target)) if err != nil { return err } @@ -438,7 +438,7 @@ func (fs *Decomposedfs) DeleteStorageSpace(ctx context.Context, req *provider.De if !strings.Contains(n.Name, node.TrashIDDelimiter) { return errtypes.NewErrtypeFromStatus(status.NewInvalidArg(ctx, "can't purge enabled space")) } - ip := fs.lu.InternalPath(req.Id.OpaqueId) + ip := n.InternalPath() matches, err := filepath.Glob(ip) if err != nil { return err diff --git a/pkg/storage/utils/decomposedfs/testhelpers/helpers.go b/pkg/storage/utils/decomposedfs/testhelpers/helpers.go index ed61673368a..06ee32e9c64 100644 --- a/pkg/storage/utils/decomposedfs/testhelpers/helpers.go +++ b/pkg/storage/utils/decomposedfs/testhelpers/helpers.go @@ -152,7 +152,7 @@ func (t *TestEnv) CreateTestFile(name, blobID, parentID, spaceID string, blobSiz if err != nil { return nil, err } - err = file.WriteAllNodeMetadata(t.Owner.Id) + err = n.WriteAllNodeMetadata(t.Owner.Id) if err != nil { return nil, err }