Skip to content

Commit

Permalink
avoid panics because they are panics (#2720)
Browse files Browse the repository at this point in the history
Signed-off-by: jkoberg <jkoberg@owncloud.com>
  • Loading branch information
kobergj authored Apr 6, 2022
1 parent f5539fc commit c7a9ff1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/grpc/interceptors/eventsmiddleware/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func NewUnary(m map[string]interface{}) (grpc.UnaryServerInterceptor, int, error
ev = FileVersionRestored(v, req.(*provider.RestoreFileVersionRequest))
}
case *provider.CreateStorageSpaceResponse:
if isSuccess(v) {
if isSuccess(v) && v.StorageSpace != nil { // TODO: Why are there CreateStorageSpaceResponses with nil StorageSpace?
ev = SpaceCreated(v)
}
case *provider.UpdateStorageSpaceResponse:
Expand Down
8 changes: 7 additions & 1 deletion internal/grpc/services/gateway/storageprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,13 @@ func (s *svc) sign(_ context.Context, target string) (string, error) {
}

func (s *svc) CreateHome(ctx context.Context, req *provider.CreateHomeRequest) (*provider.CreateHomeResponse, error) {
u := ctxpkg.ContextMustGetUser(ctx)
u, ok := ctxpkg.ContextGetUser(ctx)
if !ok {
return &provider.CreateHomeResponse{
Status: status.NewPermissionDenied(ctx, nil, "can't create home for anonymous user"),
}, nil

}
createReq := &provider.CreateStorageSpaceRequest{
Type: "personal",
Owner: u,
Expand Down

0 comments on commit c7a9ff1

Please sign in to comment.