Skip to content

Commit

Permalink
Make sharing behavior consitent with the behavior of the old backend (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
C0rby authored May 20, 2020
1 parent 05e7746 commit 9d6f232
Show file tree
Hide file tree
Showing 3 changed files with 401 additions and 374 deletions.
10 changes: 5 additions & 5 deletions internal/http/services/owncloud/ocs/conversions/permissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ const (
)

var (
// ErrPermissionAboveRange defines a permission specific error.
ErrPermissionAboveRange = fmt.Errorf("The provided permission is higher than %d", PermissionAll)
// ErrPermissionNotInRange defines a permission specific error.
ErrPermissionNotInRange = fmt.Errorf("The provided permission is not between %d and %d", PermissionInvalid, PermissionAll)
)

// NewPermissions creates a new Permissions instanz.
// The value must be in the valid range.
func NewPermissions(val int) (Permissions, error) {
if val <= int(PermissionInvalid) {
if val == int(PermissionInvalid) {
return PermissionInvalid, fmt.Errorf("permissions %d out of range %d - %d", val, PermissionRead, PermissionAll)
} else if int(PermissionAll) < val {
return PermissionInvalid, ErrPermissionAboveRange
} else if val < int(PermissionInvalid) || int(PermissionAll) < val {
return PermissionInvalid, ErrPermissionNotInRange
}
return Permissions(val), nil
}
Expand Down
Loading

0 comments on commit 9d6f232

Please sign in to comment.