Skip to content

Commit

Permalink
store nodes of a space inside of the space
Browse files Browse the repository at this point in the history
This is still work in progress. In this state the node_test.go run
successfully.
  • Loading branch information
David Christofas authored and butonic committed Feb 14, 2022
1 parent 20a38e4 commit 5a666db
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion pkg/storage/utils/decomposedfs/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions pkg/storage/utils/decomposedfs/spaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/utils/decomposedfs/testhelpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 5a666db

Please sign in to comment.