Skip to content

Commit

Permalink
eos: fixed error reporting for too large recycle bin listing (#4591)
Browse files Browse the repository at this point in the history
  • Loading branch information
glpatcern authored Mar 21, 2024
1 parent 714a3f3 commit 2f60150
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/recycle-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: eos: fixed error reporting for too large recycle bin listing

EOS returns E2BIG, which internally gets converted to PermissionDenied
and has to be properly handled in this case.

https://github.com/cs3org/reva/pull/4591
14 changes: 12 additions & 2 deletions pkg/eosclient/eosbinary/eosbinary.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,11 @@ func (c *Client) executeEOS(ctx context.Context, cmdArgs []string, auth eosclien
// eos reports back error code 1 (EPERM) when ?
// eos reports back error code 7 (E2BIG) when the user is not allowed to read the directory
// eos reports back error code 22 (EINVAL) when the user is not allowed to enter the instance
err = errtypes.PermissionDenied(errBuf.String())
errString := errBuf.String()
if errString == "" {
errString = fmt.Sprintf("rc = %d", exitStatus)
}
err = errtypes.PermissionDenied(errString)
}
}
}
Expand Down Expand Up @@ -794,7 +798,13 @@ func (c *Client) ListDeletedEntries(ctx context.Context, auth eosclient.Authoriz
args := []string{"recycle", "ls", "-m", d.Format("2006/01/02"), fmt.Sprintf("%d", maxentries+1)}
stdout, _, err := c.executeEOS(ctx, args, auth)
if err != nil {
return nil, err
switch err.(type) {
case errtypes.IsPermissionDenied:
// in this context, this is an E2BIG that gets converted to PermissionDenied by executeEOS()
return nil, errtypes.BadRequest("list too long")
default:
return nil, err
}
}

list, err := parseRecycleList(stdout)
Expand Down

0 comments on commit 2f60150

Please sign in to comment.