Skip to content

Commit

Permalink
remove user's uuid from trashbin file key
Browse files Browse the repository at this point in the history
  • Loading branch information
David Christofas committed Jun 14, 2021
1 parent 1ca0cfc commit 17f8d25
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/trashbin-file-keys.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Enhancement: Remove the user id from the trashbin key

We don't want to use the users uuid outside of the backend so I removed the id from the trashbin file key.

https://github.com/cs3org/reva/pull/1793

2 changes: 1 addition & 1 deletion pkg/storage/utils/decomposedfs/recycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (fs *Decomposedfs) ListRecycle(ctx context.Context) (items []*provider.Recy
item := &provider.RecycleItem{
Type: getResourceType(md.IsDir()),
Size: uint64(md.Size()),
Key: filepath.Base(trashRoot) + ":" + parts[0], // glue using :, a / is interpreted as a path and only the node id will reach the other methods
Key: parts[0],
}
if deletionTime, err := time.Parse(time.RFC3339Nano, parts[1]); err == nil {
item.DeletionTime = &types.Timestamp{
Expand Down
9 changes: 3 additions & 6 deletions pkg/storage/utils/decomposedfs/tree/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"github.com/cs3org/reva/pkg/errtypes"
"github.com/cs3org/reva/pkg/storage/utils/decomposedfs/node"
"github.com/cs3org/reva/pkg/storage/utils/decomposedfs/xattrs"
"github.com/cs3org/reva/pkg/user"
"github.com/google/uuid"
"github.com/pkg/errors"
"github.com/pkg/xattr"
Expand Down Expand Up @@ -632,12 +633,8 @@ func (t *Tree) readRecycleItem(ctx context.Context, key string) (n *node.Node, t
return nil, "", "", "", errtypes.InternalError("key is empty")
}

kp := strings.SplitN(key, ":", 2)
if len(kp) != 2 {
appctx.GetLogger(ctx).Error().Err(err).Str("key", key).Msg("malformed key")
return
}
trashItem = filepath.Join(t.lookup.InternalRoot(), "trash", kp[0], kp[1])
u := user.ContextMustGetUser(ctx)
trashItem = filepath.Join(t.lookup.InternalRoot(), "trash", u.Id.OpaqueId, key)

var link string
link, err = os.Readlink(trashItem)
Expand Down

0 comments on commit 17f8d25

Please sign in to comment.