Skip to content

Commit

Permalink
Clean up GetPathByID
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse Geens committed Nov 29, 2024
1 parent d604057 commit fe558e9
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions pkg/storage/utils/eosfs/eosfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,26 +487,24 @@ func (fs *eosfs) GetPathByID(ctx context.Context, id *provider.ResourceId) (stri
if err != nil {
return "", errors.Wrap(err, "eosfs: no user in ctx")
}

var auth eosclient.Authorization
if utils.IsLightweightUser(u) {
daemonAuth := utils.GetDaemonAuth()
eosFileInfo, err := fs.c.GetFileInfoByInode(ctx, daemonAuth, fid)
auth = utils.GetDaemonAuth()
} else {
auth, err = fs.getUserAuth(ctx, u, "")
if err != nil {
return "", errors.Wrap(err, "eosfs: error getting file info by inode")
}
if perm := fs.permissionSet(ctx, eosFileInfo, nil); perm.GetPath {
return fs.unwrap(ctx, eosFileInfo.File)
return "", err
}
return "", errtypes.PermissionDenied("eosfs: getting path for id not allowed")
}

userAuth, err := fs.getUserAuth(ctx, u, "")
eosFileInfo, err := fs.c.GetFileInfoByInode(ctx, auth, fid)
if err != nil {
return "", err
return "", errors.Wrap(err, "eosfs: error getting file info by inode")
}

eosFileInfo, err := fs.c.GetFileInfoByInode(ctx, userAuth, fid)
if err != nil {
return "", errors.Wrap(err, "eosfs: error getting file info by inode")
if perm := fs.permissionSet(ctx, eosFileInfo, nil); !perm.GetPath {
return "", errtypes.PermissionDenied("eosfs: getting path for id not allowed")
}

return fs.unwrap(ctx, eosFileInfo.File)
Expand Down

0 comments on commit fe558e9

Please sign in to comment.