Skip to content

Commit

Permalink
seperate different share types
Browse files Browse the repository at this point in the history
  • Loading branch information
David Christofas committed May 15, 2020
1 parent 9c91f70 commit 4b63885
Show file tree
Hide file tree
Showing 2 changed files with 317 additions and 318 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 4b63885

Please sign in to comment.